Hello friends,
Searching several web sites, I have found a great code to export contents of a listbox directly to Excel.
The only problem is that it does not export the "0" column.
My listbox has 11 columns and the code exports data starting the count from column 1. Is there a way anyone can help me with this? Thank you
Dim appExcel As Excel.Application
Dim wksData As Excel.Worksheet
Dim intColumn_Index As Integer
Dim intRow_Index As Integer
Set appExcel = New Excel.Application
appExcel.Workbooks.Add
Set wksData = appExcel.Workbooks(1).Worksheets(1)
For intRow_Index = 1 To lstStudy.ListCount ' lstStudy is the name of my list box
For intColumn_Index = 1 To lstStudy.ColumnCount
wksData.Cells(intRow_Index + 1, intColumn_Index).Value = lstStudy.Column(intColumn_Index, intRow_Index) ' this is the line I get the error
Next intColumn_Index
Next intRow_Index
appExcel.Visible = True
Set wksData = Nothing
Set appExcel = Nothing
End Sub
Searching several web sites, I have found a great code to export contents of a listbox directly to Excel.
The only problem is that it does not export the "0" column.
My listbox has 11 columns and the code exports data starting the count from column 1. Is there a way anyone can help me with this? Thank you
Dim appExcel As Excel.Application
Dim wksData As Excel.Worksheet
Dim intColumn_Index As Integer
Dim intRow_Index As Integer
Set appExcel = New Excel.Application
appExcel.Workbooks.Add
Set wksData = appExcel.Workbooks(1).Worksheets(1)
For intRow_Index = 1 To lstStudy.ListCount ' lstStudy is the name of my list box
For intColumn_Index = 1 To lstStudy.ColumnCount
wksData.Cells(intRow_Index + 1, intColumn_Index).Value = lstStudy.Column(intColumn_Index, intRow_Index) ' this is the line I get the error
Next intColumn_Index
Next intRow_Index
appExcel.Visible = True
Set wksData = Nothing
Set appExcel = Nothing
End Sub