Sequential excel outputs: How to write to a new column?
Hi everyone!
I have looked up this problem in old threads and can't find an answer that I can get to work. This is the closest I've come: http://www.vbforums.com/showthread.p...cel+sequential
I'm working on creating an excel output from a VB6 program.
For the following code, I would like to specify the cell that the information in each line should be written to. Even better, I'd like to be able to put parts of each line in separate cells (e.g., the string "Subject age" in column 1 and the value "24" in column 2).
Code:
Private Sub Command1_Click()
Open File_Name & ".xls" For Output As #1
Write #1, "STAGE 1A"
Write #1, "Subject name: " & Subject_Name
Write #1, "The file name: " & File_Name
Write #1,
Write #1, "DEMOGRAPHICS"
Write #1, "Subject age: " & age
Write #1, "Subject gender: " & gender
Write #1, "Subject ethnicity: " & ethnicity
Write #1,
Can anyone shed some light on how to do this? It must be simple, but I'm very inexperienced. I'd greatly appreciate any tips. "File_Name", "age" etc. are obviously variables defined elsewhere in the program. The above code works fine for creating an excel file as a list.
Many thanks for taking the time!
Re: Sequential excel outputs: How to write to a new column?
Here's my sample code for creating an excel file from vb6... currently deployed in our system
VB Code:
Dim xl As New Excel.application
Dim xlsheet As Excel.Worksheet
Dim xlwbook As Excel.Workbook
Set xl = CreateObject("Excel.Application")
Set xlwbook = xl.Workbooks.Add
Set xlsheet = xlwbook.Sheets(1)
xlsheet.Cells(1, 1) = "SAMPLE"
xl.Visible = True
xlwbook.Close
xl.Quit
Set xl = Nothing
Set xlwbook = Nothing
Set xlsheet = Nothing