Listbox Rowsource Worksheet Name From ComboBox Value

gugumnd

New Member
Joined
May 27, 2018
Messages
8
Hi,

Can I use a combo box value (comboBox1.value) in Listbox Rowsource worksheet property? See example below:

With userForm1.Listbox1
.RowSource = userForm1.comboBox1.value & "!A1:B10"
.ColumnHeads = True
.ColumnCount = 2
.ColumnWidths = "100;120"
End With

I have several sheets with different lists. I want the program to populate Listbox1 depending on the value selected from comboBox1. I was able to successfully populate the list box by using the specific worksheet name (see below).

With userForm1.Listbox1
.RowSource = "Sheet1!A1:B10"
.ColumnHeads = True
.ColumnCount = 2
.ColumnWidths = "100;120"
End With

Thanks for any help.
Gugu
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I apologize to my mistake. The first program code really works. I just made a type error in my code. It works now.

Thanks,

Gugu
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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