ListBox Show Multiple columns

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
On my userform I have a List box and in the properties I see it asks for Bound Column, Column Count... So I assume you can show more than one column in the list.

RowSource: Drop_Down_Lists!$J$3:$K$100

I set the column count to 2 the bound column I set to 2 and I made the widths so that it should show two (1 pt;0.5 pt)

But when I open the form, I only see the data from the 2nd column in the list.

And when I make selections, its putting the data from column 1 in my selected area.

What am I doing wrong?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Re: ListBox Show Mutilpe columns

MAIT

Here is the exact code I used. And yes, I removed Rowsource.....

Code:
Private Sub UserForm_Initialize()
Dim Data As Variant
Dim lastrow As Long

lastrow = Sheet6.Cells(Rows.Count, "K").End(xlUp).Row
ListBox1.BoundColumn = 2
ListBox1.ColumnCount = 1
ListBox1.ColumnWidths = "20;20"
Data = Sheets("DROP_DOWN_LISTS").Range("J3:K" & lastrow)
ListBox1.List = Data

End Sub

I did modify yours slightly by adding the sheet name (Data = Sheets("DROP_DOWN_LISTS").Range("J3:K" & lastrow))
 
Upvote 0
Re: ListBox Show Mutilpe columns

Why do you have this if you want 2 columns displayed?
Rich (BB code):
ListBox1.ColumnCount = 1
 
Upvote 0
Re: ListBox Show Mutilpe columns

I was able to fix which column the data was being used from. Making the change to "varSelected(i) = .List(x,1)" fixed it.

But I still only see one column (the first one - the info from column J in my spreadsheet).

Here is the exact code. I am using what MAIT sent me with a slight modification to the Data/Range

Code:
Private Sub UserForm_Initialize()
Dim Data As Variant
Dim lastrow As Long

lastrow = Sheet6.Cells(Rows.Count, "K").End(xlUp).Row
ListBox1.BoundColumn = 2
ListBox1.ColumnCount = 1
ListBox1.ColumnWidths = "20;20"
Data = Sheets("DROP_DOWN_LISTS").Range("J3:K" & lastrow)
ListBox1.List = Data

End Sub

I would think this sets the column widths in the list box to 20 and 20 which should show something, but like I said; all I see on my form is the data from column J. The data from column K is not visible in the Listbox
 
Upvote 0
Re: ListBox Show Mutilpe columns

One thing I see is your using two different sheet names:

Your using Sheet6

And sheet:

Sheets("DROP_DOWN_LISTS")

 
Upvote 0
Re: ListBox Show Mutilpe columns

But I still only see one column (the first one - the info from column J in my spreadsheet).
That's because (as Norie pointed out) you have this
Code:
ListBox1.ColumnCount = 1
Change it to 2
 
Upvote 0
Re: ListBox Show Mutilpe columns

I notice that now myself.
I provided this code
Which shows column count as 2
Why did you change it to 1 ??

Code:
[LEFT][COLOR=#333333][FONT=monospace]Private Sub UserForm_Initialize()
'Modified  10/30/2018  9:07:29 PM  EDT
Dim Data As Variant
Dim lastrow As Long
lastrow = Sheet1.Cells(Rows.Count, "K").End(xlUp).Row
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "20;20"
Data = Range("J2:K" & lastrow)
ListBox1.List = Data
End Sub[/FONT][/COLOR][/LEFT]
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top