i have the following function that im using to populate a userform listbox with data from an array:
Function PopulateListboxWithArray(lstbox As MSForms.ListBox, var As Variant)
With lstbox
If Not IsEmpty(var) Then
.Clear
.list = Application.Transpose(var)
.ListIndex = -1
End If
End With
End Function
My listbox contains two columns with the following properties:
PROBLEM
The data in the array has an ID column and a lastname column. I dont want the user to see the ID column so ive set that column width to 0 in the form.
When i import data that has more than one row, the data shows up in the listbox as expected.
However, when the array only contains one row of data, the listbox shows up blank !
I have tried deleting the columnwidths in the image above and when i do so and reimport the one row of data, i get the ID and lastname stacked on top of one another. But ofcourse this is not the result i want.
I have even tried replacing .list = Application.Transpose(var)
with .list = var
to no avail.
What am i doing wrong here, or is there a better way to populate a listbox?
cheers