[英]Excel extract all data of drop down list into Column
I have copied a drop down list cell from other sheet and trying to fetch its all items name. 我已经从其他工作表中复制了一个下拉列表单元格,并试图获取其所有项目名称。 Dropdown list is created through excel property by this link, not using Combo Box . 下拉列表是通过excel属性通过此链接创建的,而不是使用Combo Box 。 Is there any way to get all items of drop down list ? 有什么方法可以获取下拉列表中的所有项目? Means get the original list which is mapped to the drop down. 均值获取映射到下拉列表的原始列表。
I tried to get it through VB Script also but it does not work. 我也尝试通过VB脚本来获取它,但是它不起作用。
Dim dd As DropDown
Set dd = ActiveSheet.DropDowns("MyDropDown")
When I debug that code it show "unable to get the dropdowns property of the worksheet class" error at 当我调试该代码时,它显示“无法获取工作表类的dropdowns属性”错误
Set dd = ActiveSheet.DropDowns("MyDropDown")
line and this Excel dropdowns in VBA: "Unable to get the DropDowns property of the Worksheet class" not helped me. 行和VBA中的此Excel下拉列表:“无法获取Worksheet类的DropDowns属性”对我没有帮助。 Is ActiveSheet.DropDowns("MyDropDown") works only for Combo Box ? ActiveSheet.DropDowns(“ MyDropDown”)仅适用于组合框吗? Then how I get all items either using excel property or VB Script? 然后,如何使用excel属性或VB脚本获取所有项目?
Ah, your original question didn't make it clear that you were using Data Validation. 嗯,您最初的问题并不清楚您使用的是数据验证。 To loop through all the items in a Data Validation list, you can use this code: 要遍历数据验证列表中的所有项目,可以使用以下代码:
Sub loopthroughvalidationlist()
Dim inputRange As Range
Dim c As Range
' Change range below to first cell in your list
Set inputRange = Evaluate(Range("J6").Validation.Formula1)
For Each c In inputRange
MsgBox (c)
Next c
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.