Quote Originally Posted by ruslannurijev View Post
Hi!

I have managed to get all the data from ListBox without using ".List" property.
After hours of studing ListBox and figuering out why my code pulls only first column from the listbox i came to conclusion that it is the BoundColumn that i must use.

So i loop the BoundColumn value. But at the end of the loop i must manually set BoundColumn value to 1, couse when the export is finished the BoundColumn has value 7(this is in my case, couse i have 6 columns). If i wont set value to 1 then the next time i will get a blank Excel Worksheet, that is bacause BoundColumn still holds value 7 and there is no column 7 in my ListBox.

Code follows:
Code:
Private Sub ReportToExcel_Click()
'EXPORT to EXCEL
Dim myExApp As Excel.Application    'variable for Excel App
Dim myExSheet As Excel.Worksheet    'variable for Excel Sheet
Dim i As Long                       'variable for ColumnCount
Dim j As Long                       'variable for ListCount
Set myExApp = New Excel.Application

myExApp.Visible = True              'Sets Excel visible
myExApp.Workbooks.Add               'Add a new Workbook
Set myExSheet = myExApp.Workbooks(1).Worksheets(1)

For i = 1 To ReportRecordList.ColumnCount   'Counter for ColumnCount
    ReportRecordList.BoundColumn = ReportRecordList.BoundColumn + 1 'Setting counter for BoundColumn
    For j = 1 To ReportRecordList.ListCount 'Counter for ListCount
        myExSheet.Cells(j , i) = ReportRecordList.ItemData(j - 1)    'Insert ItemData into Excel Worksheet
    Next j  'Iterating through ListCount
Next i  'Iterating through ColumnCount
ReportRecordList.BoundColumn = 1    'Setting BoundColumn to original 1

Set myExSheet = Nothing 'Release Worksheet
Set myExApp = Nothing   'Release Excel Application

End Sub

Thanks for trying to help, i hope that this Thread will help others to solve same problems.

Best Regards,
Ruslan.
This code is fine but how to I can export with name field ???

Many Thanks