Combobox & named ranges

Bernieg

Board Regular
Joined
Jan 1, 2009
Messages
147
Office Version
  1. 365
Platform
  1. Windows
Hi
I have 2 comboboxs in a userform
box2 = Part no. & box1= Op No.

op no is based on part no., the code below does work....however
if the form is opened on a page that is not the source of the named ranges the rowsource only reflects the actual range of the named range
i.e A6:A36 it does not know what page the info is on.

if i manualy type in = NQF005025 in the rowsource it workes

Private Sub ComboBox2_Change()
ComboBox1.Value = "" ' value empty by default
'changes the rowsource data(named range)of combobox1 based on the text selected in combobox2
ComboBox1.RowSource = ActiveWorkbook.Names(ComboBox2.Value).RefersToRange.Address
End Sub

Bernie ;)
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Bernie

If you can manually type the name for the RowSource you should be able to do it in code.
Code:
ComboBox1.RowSource = ComboBox2.Value

Have you tried that?
 
Upvote 0
Cheers, I thought you were going to come back and say it didn't work because it did seem kind of easy.

Thought I must have missed something somewhere.:)

PS Knowing my luck you'll post back in 5 minutes saying it didn't work.:eek:
 
Upvote 0
Hi Norie
I also pre load the part no. combos wih named ranges

ComboBox2.RowSource = "parts"
ComboBox3.RowSource = "parts"

Do you know how to change the combobox forecolor in code

Bernie
 
Upvote 0
Bernie

I though you only had 2 comboboxes?

Anyway, what is it you want to do?

Change the font (fore) colour based on what's in the combobox, what's selected in it...
 
Upvote 0
I have some checkboxs with some code that checks at least 1 is checked
If not it turn the forecolor red with message

Bernie
 
Upvote 0
Bernie

I'm sorry, I must be missing something here.:eek:

What exactly do you have? Comboboxes and checkboxes?
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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