Userform Combo box needs a variable row source.

braindiesel

Well-known Member
Joined
Mar 16, 2009
Messages
554
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
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
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?
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,376
Your code worked for me.

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

What error do you get?
 

braindiesel

Well-known Member
Joined
Mar 16, 2009
Messages
554
Office Version
  1. 365
  2. 2019
  3. 2010
Platform
  1. Windows
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?
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,376
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:

braindiesel

Well-known Member
Joined
Mar 16, 2009
Messages
554
Office Version
  1. 365
  2. 2019
  3. 2010
Platform
  1. Windows
It was the userform name missing.

Thanks for the help
 

Watch MrExcel Video

Forum statistics

Threads
1,122,232
Messages
5,594,956
Members
413,954
Latest member
mrsandy

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
Top