In an Excel UserForm, you can add combo boxes to make data entry easier. The UserForm in this example is used to enter parts information onto a hidden inventory sheet.
在Excel UserForm中 ,您可以添加组合框以简化数据输入。 本示例中的UserForm用于将零件信息输入到隐藏的库存表中。
Before selecting a Part ID, you have to select a Part Type. When the Part Type combo box is updated, code runs, and creates a list of parts, for the selected part type.
在选择零件ID之前,您必须选择一个零件类型。 更新“零件类型”组合框后,代码将运行,并为所选零件类型创建零件列表。
这个怎么运作 (How It Works)
In the background, an Advanced Filter runs, to create a worksheet list of parts for the selected part type.
在后台运行“ 高级筛选器” ,以为所选零件类型创建零件的工作表列表。
That list is set up as a named range, and the range name is used as the Part ID combo box row source.
该列表设置为一个命名范围 ,范围名称用作“零件ID”组合框行源。
观看视频 (Watch the Video)
To see how the dependent combo boxes work, watch this short video.
要查看从属组合框的工作方式,请观看此简短视频。
下载样本文件 (Download the Sample File)
To test the dependent combo boxes on the UserForm, and to see the code, go to my Contextures website, and download the sample file.
要测试UserForm上的从属组合框并查看代码,请转到我的Contextures网站,然后下载示例文件 。
翻译自: https://contexturesblog.com/archives/2013/03/07/excel-userform-with-dependent-combo-boxes/