Userform Combo box needs a variable row source.

braindiesel

Well-known Member
Joined
Mar 16, 2009
Messages
571
Office Version
  1. 365
  2. 2019
  3. 2010
Platform
  1. Windows
Hello,

I have a userform (called "adjustprod")
On it I have a combobox called "adjustbox"
The row source is a range called adjustProdList1, adjustProdList2 or adjustProdList3 depending if you launch the box from my year 1, year 2 or Year 3 sheet.
In cell A1 on each of the sheets is a 1, 2, or 3 respectively

Is there a way I can have the variable row source or do I need three userforms?

If so do I put the code in immediately before the launch, as I have tried below (which yields an error) or is there somewhere I put is for when I launch the userform?

adjustBox.RowSource = Range("adjustProdList" & Range("a1").Value).Address
AdjustProd.Show
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Code:
[/FONT]
[FONT=Courier New]you launch the box from my year 1, year 2 or Year 3 sheet.[/FONT]
[FONT=Courier New]In cell A1 on each of the sheets is a 1, 2, or 3 respectively[/FONT]
[FONT=Courier New]

What is this 1, 2 and 3? is this a button? how does your form show?
 
Upvote 0
Your code worked for me.

Code:
adjustBox.RowSource = Range("adjustProdList" & Range("a1").Value).Address

What error do you get?
 
Upvote 0
I'm getting a runtime error 424

if the code is working, then the problem must be where I am supposed to put it.

Do I declare the source BEFORE I show the userform?
or
if not, how do I get the source to be declared upon launching the form?
 
Upvote 0
Your combobox is not named adjustBox

Or you might have to reference the userform...
adjustprod.adjustBox.RowSource = Range("adjustProdList" & Range("a1").Value).Address
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,736
Members
448,988
Latest member
BB_Unlv

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