Excel VBA 组合框返回索引不是值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10029001/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 15:45:01  来源:igfitidea点击:

Excel VBA Combo Box returning index not value

comboboxexcel-vbavbaexcel

提问by SomethingSmithe

I've got a combo box set up in Excel 2007 which gathers its list items from another sheet. When I try to access the value of the selected item through a macro all I am returned is the index value and not the actual value.

我在 Excel 2007 中设置了一个组合框,它从另一个工作表中收集其列表项。当我尝试通过宏访问所选项目的值时,我返回的只是索引值而不是实际值。

DateDropDown = Sheets("Input Form").Shapes("APPDateDropDown").ControlFormat.Value

The value in the combo box is listed as "Jan-12" but when I run the code above DateDropDown is returned as 37 (the index of the item).

组合框中的值被列为“Jan-12”,但是当我运行上面的代码时 DateDropDown 返回为 37(项目的索​​引)。

How do I get it to return the value "Jan-12"?

我如何让它返回值“Jan-12”?

采纳答案by Siddharth Rout

With Sheets("Input Form").Shapes("APPDateDropDown")
    DateDropDown = .ControlFormat.List(.ControlFormat.ListIndex)
End With