Cannot view dropdown list in Excel VBA

I created a very simple drop down list in excel. It contains a sequence of integers loaded from a range of cells (years). I need to read the selected value in vba. However, I can’t even find control!

I tried

CboYear Sheet2.CboYear Worksheets("SheetName").CboYear 

etc .. and others.

Throughout VBA, this control simply does not exist. All the tutorials that I find suggest that using just the name of the control will work.

I tried the code in the sheet itself, the book and the module, no luck.

+4
source share
2 answers

If you got a dropdown in the form bar, use

 Sheet2.DropDowns("CboYear") 

The DropDowns property is not supported / deprecated, so you will not get intellisense, but it still works.

If you got the Control Toolbox drop-down menu, then

 Sheet2.CboYear 

must work

+3
source

There are two types of control sets used by Excel. Built-in controls and Microsoft Forms 2.0 control. The built-in controls available on the Forms toolbar are controls specifically designed for working in Excel and using ranges. Other controls are Microsoft Forms 2.0 controls. These are the ActiveX controls that Office VBA uses. They are designed to work inside Office and are more similar to the controls used by Windows.

0
source

Source: https://habr.com/ru/post/1305143/


All Articles