Retrieving a ComboBox value

gemcgraw

Board Regular
Joined
Mar 11, 2011
Messages
72
Good day everyone. Where has the year gone!

I've been ripping my code to pieces trying to write this one simple line; however, I can't get my head around it.

I need to pull a value already populated in ComboBox1 from Sheet-B then assign that value to a variable on Sheet-A. I just can't figure out what I'm missing.

Thanks for any help!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
What kind of combobox are you using, ActiveX, from the Forms menu or on a Userform?

I'm confused by "assign it to a variable on sheet A"
Sheet's don't have variables, they have cells.
 
Upvote 0
What kind of combobox are you using, ActiveX, from the Forms menu or on a Userform?

I'm confused by "assign it to a variable on sheet A"
Sheet's don't have variables, they have cells.

I writing in VBA and using a ComboBox activeX control. The combobox1 (as I have named it) resides on Sheet-B and has a value of "12". From Sheet-A, I want to "reach over" to that combobox1 and get the value of "12" and make the variable "RowColor" on Sheet-A equal that value of "12".
 
Upvote 0
This worked for me to get the value selected in the combobox.
Code:
Dim myVar As String
myVar = Sheets("sheet2").ComboBox1.Value
 
Upvote 0
This worked for me to get the value selected in the combobox.
Code:
Dim myVar As String
myVar = Sheets("sheet2").ComboBox1.Value

That was it! I failed to DIM the variable first and was getting odd results. Thanks so much for the tip.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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