Populate drop down from SQL table

Balthazar

New Member
Joined
Sep 28, 2016
Messages
7
I want to populate a combo box from a SQL table. I have an immediate problem in that when I create the combo box I cannot refer to it. It takes a default name of dropdown1, but when I attempt to reference this in VBA using:

Code:
With Sheets("Sheet2").dropdown1

I get an error:

Run time error 438
Object doesn't support this property or method.

I also notice that if I rename the object by right-clicking it then editing the name that appears in the Excel name window, Excel still calls the control 'dropdown1'.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
How did you create the combobox?
 
Upvote 0
Try using this to get a reference to the combobox.
Code:
Dim cmb As Object

    Set cmb = Sheets("Sheet1").Shapes("Drop Down 1")
 
Upvote 0
Try using this to get a reference to the combobox.
Code:
Dim cmb As Object

    Set cmb = Sheets("Sheet1").Shapes("Drop Down 1")

OK, that doesn't throw an error but how do I add an item to the list? AddItem doesn't do anything.
 
Upvote 0

Forum statistics

Threads
1,223,948
Messages
6,175,580
Members
452,653
Latest member
craigje92

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