如何使用 VBA 在 Excel 中读取工作表上下拉列表的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2027254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to read the value of a drop down list on a sheet in Excel using VBA
提问by Dafydd Giddins
As per the title, i have a drop down list which is already populated. On a button command i want to read the selected value from this drop down list which i will use to drive an ADO query.
根据标题,我有一个已经填充的下拉列表。在按钮命令上,我想从这个下拉列表中读取选定的值,我将用它来驱动 ADO 查询。
I did VBA in Access years ago so have some idea of what i am doing but using it in Excel is new to me.
几年前我在 Access 中做过 VBA,所以对我在做什么有一些了解,但在 Excel 中使用它对我来说是新的。
As a side question can anybody point me in the direction of reference material for the types available in VBA excel or any VBA Excel programming resources?
作为一个附带问题,任何人都可以向我指出 VBA excel 或任何 VBA Excel 编程资源中可用类型的参考资料方向吗?
Thanks
谢谢
回答by Intrigue
With ActiveSheet.Shapes("Drop Down 1").ControlFormat
MsgBox "Index chosen = " & .Value
MsgBox "Item chosen = " & .List(.Value)
End With

