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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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