在VBA中获取下拉列表值,并获取下拉列表的名称,无法找到? [英] Get dropdown value in VBA and get the name of the dropdown...nowhere to be found?

查看:729
本文介绍了在VBA中获取下拉列表值,并获取下拉列表的名称,无法找到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从UserForm工具栏中将组合框拖到我的工作表上创建了一个下拉列表。我从书中的一些单元格中分配了一些值。现在我想要一些VBA代码以字符串的形式访问所选的下拉列表项的值。

I created a dropdown by dragging the combo box onto my sheet from the UserForm toolbar. I assigned some values to it from some cells in the book. Now I want some VBA code to access the selected dropdown item's value in the form of a string.

我的下拉列表中只包含文本。

My dropdown contains only text.

此外,如何查找此新创建的下拉列表的名称(它是

Also how do I find the name of this newly created dropdown (it's nowhere in the properties!)?

推荐答案

Dim dd As DropDown
Set dd = ActiveSheet.DropDowns("Drop Down 6") 
Set r = Sheet2.Range(dd.ListFillRange)

Set ddValue = r(dd.Value)

注意:


  • DropDown不是可见的类。
    只是使用它,它可以工作。

  • DropDown is not a visible class. You just use it and it works.

要查找下拉列表的名称
CONTROL 不是用户窗体)只需查看

屏幕左上角的名称框,就在列A上方。
它表示控件的名称,当
时,您右键单击您的控制.-

To find the name of the dropdown CONTROL (not userform) just look at
the name box in the top left corner of your screen just above column A. It says the name of the control when you right click on your control.-

Sheet2是下载列表为
填充的位置。所以无论你的列表数据是
是什么。

Sheet2 is where the dropdown list is populated. So wherever your list data is.

希望能帮助你。

这篇关于在VBA中获取下拉列表值,并获取下拉列表的名称,无法找到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆