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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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,216,051
Messages
6,128,505
Members
449,455
Latest member
jesski

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