I get an error called (Run-time error '13' ; Type mismatch). Im new to VBA so sorry if this is a stupid question.
BaseForm = my userform
Dim iRow & iCol as integer
Sub refresh_data() ' refresh the listbox data
Set ws = ThisWorkbook.Sheets("DATA")
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
iCol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
 
With BaseForm
    .ListBox1.ColumnCount = iCol
    .ListBox1.ColumnHeads = True
    
    If iRow > 1 Then
    .ListBox1.RowSource = Range(Cells(1, 1), Cells(iRow, iCol))
    
    Else
    .ListBox1.RowSource = Range(Cells(1, 1), Cells(1, iCol))
    End If
End With
End Sub
 
    