Hello,
I would like to display data from an excel sheet ("Test") in an UserForm listview. I have 12 columns and 500 rows in my sheet table. In the code, message error keep pop-in as "Run-time error 13. Type mismatch". Could you please help me with that issue?
Thank you
I would like to display data from an excel sheet ("Test") in an UserForm listview. I have 12 columns and 500 rows in my sheet table. In the code, message error keep pop-in as "Run-time error 13. Type mismatch". Could you please help me with that issue?
Thank you
VBA Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim rg As Range
Dim i As Integer
Dim j As Integer
Set ws = ThisWorkbook.Sheets("Test")
Set rg = ws.Range("refTab")
With UserForm3.ListView1
For i = 1 To 12
.ColumnHeaders.Add , , rg.Offset(0, i - 1)
Next i
For i = 1 To 500
.ListItems.Add , , rg.Offset(i, 0)
Next i
For i = 1 To 500
For j = 1 To 11
.ListItems(i).ListSubItems.Add , , rg.Offset(i, j)
Next j
Next i
.View = lvwReport
End With
End Sub
Last edited by a moderator: