Saturday, September 1, 2018

Can't see drop down list in Excel VBA




I've created a very simple drop down list in excel. It holds a sequence of integers loaded from a cell range (years). I need to read the selected value in vba. However I can't even seem to find the control!



I've tried



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


etc. etc.




From everywhere in VBA this control just doesn't exist. All the tutorials I find seem to assume that using just the control name will work.



I've tried the code in the sheet itself, the workbook, and a module, no luck.


Answer



If you got the drop down from the Forms toolbar, use



Sheet2.DropDowns("CboYear")



The DropDowns property is unsupported/deprecated so you won't get intellisense, but it still works.



If you got the drop down from the Control Toolbox, then



Sheet2.CboYear


should work


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...