Possible Duplicate:
Adding items in a Listbox with multiple columns
With MFC VC++ there are two controls, ListBox
and ListCtrl
. But with VBA it seems we have only ListBox
.
I want to create a listbox with 2 columns (Company_ID, Company_Name).
Here is what I tried:
In the VBA code routine I added the following lines:
lstbox.ColumnCount = 2
lstbox.AddItem (Company_ID)
The following code is not working which seems to be related with adding column value:
lstbox.Column(1,lstbox.ListCount - 1) = Company_name
This gives error:
Runtime error '424' object required.
Could anyone help with vba code to add to multi column listbox.
Simplified example (with counter):
With Me.lstbox
.ColumnCount = 2
.ColumnWidths = "60;60"
.AddItem
.List(i, 0) = Company_ID
.List(i, 1) = Company_name
i = i + 1
end with
Make sure to start the counter with 0, not 1 to fill up a listbox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With