Problem: Objective is to export the data from ListBox1 and then separately export the headers. Data export OK, no problem. Header throws a runtime error 13, type mismatch. Do you guys know why? How can I fix this?
Private Sub ButtonSearchExport_Click()
Dim wb As Workbook
Set wb = ActiveWorkbook '<<<< After export data, return to this original wb.
With Workbooks.Add
.Sheets(1).Range(Cells(2, 1), Cells(Me.ListBox1.ListCount, Me.ListBox1.ColumnCount)) = Me.ListBox1.List
''''''''<<<< The error is from the line here:
.Sheets(1).Range(Cells(1, 1), Cells(Me.ListBox1.List(0), Me.ListBox1.ColumnCount)) = Me.ListBox1.List(0)
Sheets(1).Name = "Transfer"
End With
wb.Activate
End Sub