VBA: how to reference a ComboBox object

I created a single ComboBox on the first sheet in Excel. However, I cannot find a way to refer to its object.

I inserted a module and one of my sub-sites can successfully reference the following value:

Sheets ("Sheet1"). Name

However, the following is not available and generates an error:

ComboBox1.Value

Error message: Run-time error "424": Object required

Can someone please explain how to reference this ComboBox in my sheet? Thanks to

+3


source to share


1 answer


It depends on the type of combo box you created:

  • Shape control :Sheets("Sheet1").DropDowns(1)

  • ActiveX Control :Sheets("Sheet1").ComboBox1



Sheets("Sheet1").

can be omitted if the code is placed inside a VBA module Sheet1

.

Also see What is the difference between "Form Controls" and "ActiveX Control" in Excel 2010?

+3


source







All Articles