BACKGROUND
I am developing a userform in ms excel to provide a 'dashboard' for data spread over several worksheets. The userform presents a combobox and from that selection, the listbox is populated. The userform also allows the listbox information to be copied by a 'COPY' button. The rowsource for the listbox can be a single column (e.g., Budget!$L$191) or several columns & rows (e.g., JKG.Slave!$I$38:$JM$44).
I have selected the 'MultiSelect' property in the listbox properties.
CHALLENGES
How do I display all rowsource data in a multicolumn (if needed) listbox?
How do I dynamically capture the column count needed to support the multicolumn listbox?
Can I use a variable to capture the column count and have it populate the listbox at runtime?
CODE SAMPLE FROM PROJECT
Public Sub ComboBox1_Change()
Dim cSelect As String
Dim lcount As Integer
cSelect = UserForm2.ComboBox1.Value
UserForm2.ListBox1.RowSource = cSelect
lcount = UserForm2.ComboBox1.ColumnCount
MsgBox lcount
End Sub
The variable lcount returns one (1) even when the rowsource is the multiple rows & multiple columns selection.
Thank you all for the help.
Here I modified my answer to Excel ComboBox - Autosize Dropdown Only to adjust the
Column
counts andListWidths
of a ComboBox or ListBox.Usage