Passing worksheet ActiveX combobox value to VBA code

Dr.K

Board Regular
Joined
May 16, 2007
Messages
83
I've gotten very good with comboboxes in UserForms, but this is the first time I've tried putting one directly onto a worksheet.
I have a worksheet for entering using the user's personal info. There are four cells for the user to enter, and then two cmdButtons to launch macros that use this information.

I need to make the department field a combobox, so that the tracking database has consistent departments. The combobox pulls its list from a hidden worksheet, but eventually will pull from an Access table.

The problem is, how do I pass the combobox.value to the code?

I tired useing ComboBox1.value =, but it gave me an "Object Required" error. Is there a way to make this value public? or is it trapped on the sheet from which it came? I tried using worksheets("User Data").combobox1.value, but this errored too. Maybe I need to assign a public variable in the worksheet code?

My current work around stinks: I've got a cell under the box which is linked to box, and then I pull my data from the cell. Works great from a VBA perspective, but I had do a bunch of voodoo to keep the user from directly selecting or editing the cell.
 
You can (should be able to) use the sheet reference:

Code:
Sheets("Sheet1").ComboBox1.Value

What error do you get trying that method?

Smitty
 
Upvote 0
DOH! That works. :oops:

I must have made a typo when I tried that earlier.
Thank you for the assistance.
 
Upvote 0

Forum statistics

Threads
1,226,795
Messages
6,193,047
Members
453,772
Latest member
aastupin

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