VBA ActiveX Combobox reference

Damian86

New Member
Joined
Jun 30, 2014
Messages
47
Hi guys!

I can't change/read any of my activeX combobox properties without getting an error. I can address and modify my combobox via this code:

Code:
ActiveSheet.Shapes.Range(Array("My_Combobox_Name")).Select
With Selection
.ListFillRange = "MySheet!" & MyRange.Address
.LinkedCell = "A1"
.Object.BackColor = &HC0C0C0
.Placement = xlFreeFloating
End With

As you can see, I change 4 properties with this code: ListFillRange from another sheet, linked cell address, background color and make it free float.

The problem is, I want to refer to the combobox directly, without having to activate the sheet with it and then activating the combobox itself. Is there a way? I tried various combinations with using its name but I cannot get it to work. I've read different solutions but I don't think they apply to my problem since they refer to OLEObjects.

Thank you for oyur help!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Instead of:

Code:
With Selection

you can use eg:

Code:
With Worksheets("Sheet1").OLEObjects("My_Combobox_Name")

Change the worksheet reference to suit.
 
Upvote 0
An ActiveX combobox is contained in an OLEObject if it's on a worksheet. Try:
Code:
With Sheets("Sheet name").OLEObjects("My_Combobox_Name")
.ListFillRange = "MySheet!" & MyRange.Address
.LinkedCell = "A1"
.Object.BackColor = &HC0C0C0
.Placement = xlFreeFloating
End With
 
Upvote 0

Forum statistics

Threads
1,217,331
Messages
6,135,934
Members
449,973
Latest member
jarzack

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