简体   繁体   English

条件/级联/从属下拉列表

[英]Conditional/cascading/dependent drop-down list

I am essentially trying to do that this guy is trying to do: Excel drop-down list using vLookup 我实质上是想做这个家伙想要做的事情: 使用vLookup的Excel下拉列表

I've gone through the steps and since my data set has about 400 different drop down options I am hoping there is an easier way than naming ranges. 我已经完成了这些步骤,并且由于我的数据集具有大约400个不同的下拉选项,所以我希望有一种比命名范围更简单的方法。 I have a list of about 400 different account names. 我有大约400个不同帐户名的列表。 Each of these account names is tied to a household and identified by the household ID number. 这些帐户名中的每一个都与一个家庭相关联,并由家庭ID号标识。 A household can have anywhere from 1-5 account names. 一个家庭可以有1-5个帐户名。 I would like for my drop down menu to be able to identify a household ID number and then provide the drop down with the account names associated with it. 我希望下拉菜单能够识别住户ID号,然后为下拉菜单提供与其关联的帐户名。

Example: 例:

数据

Where household Id number is the identifier. 其中,住户编号是标识符。

I've gone here as well http://sites.madrocketscientist.com/jerrybeaucaires-excelassistant/data-validation/dynamic-indirect and am trying to find a way to save on some of the manual work.I am a total newbie so thank you in advance for any help you can provide. 我也去过这里http://sites.madrocketscientist.com/jerrybeaucaires-excelassistant/data-validation/dynamic-indirect,并试图找到一种节省一些手工工作的方法。预先感谢您提供的任何帮助。

Let's pretend you have three worksheets. 假设您有三个工作表。 The first worksheet, Sheet1 , is the sheet that your users will be looking at and it has the drop down lists. 第一个工作表Sheet1是您的用户将要查看的工作表,并且具有下拉列表。 We'll say that the cell containing the first drop down option is in B1 (the one with about 400 different options) and the cell containing the dependent drop down is in B2: 我们将说,包含第一个下拉选项的单元格在B1中(具有大约400个不同选项的单元格),而包含从属下拉列表的单元格在B2中:

Sheet1示例

On your second sheet, which we'll call MasterList , is all of the data options and the corresponding data. 在第二张纸上,我们将其称为MasterList ,其中是所有数据选项和相应的数据。 Row 1 is a header row; 第1行是标题行; Row 2 and down is the actual data: 第2行及以下是实际数据:

MasterList示例

On your third sheet, which we'll call DropDownLists , is where the magic happens. 在您的第三张纸上,我们将其称为DropDownLists ,这就是魔术发生的地方。 It first needs to have a list of all the unique data options. 首先需要具有所有唯一数据选项的列表。 I've put that in column A. You can get the unique data options from your master list through whatever means you prefer (Advanced Filter, Pivot Table, formula, VBA, etc). 我已将其放在A列中。您可以通过自己喜欢的任何方式(高级过滤器,数据透视表,公式,VBA等)从主列表中获得唯一数据选项。 That list of unique data options is the basis of your drop down list for Sheet1 cell B1. 该唯一数据选项列表是Sheet1单元格B1的下拉列表的基础。 Then in cell B2 of DropDownLists and copied down as far as needed to guarantee it will grab all data associated with the selected Data Option, use this formula (adjust sheet names and ranges to suit your actual data): 然后在DropDownLists单元格B2中并根据需要向下复制,以确保它将捕获与所选Data Option相关的所有数据,请使用以下公式(调整工作表名称和范围以适合您的实际数据):

=IF(OR(Sheet1!$B$1="",ROW(B1)>COUNTIF(MasterList!$A$2:$A$10000,Sheet1!$B$1)),"",INDEX(MasterList!$B$2:$B$10000,MATCH(1,INDEX((MasterList!$A$2:$A$10000=Sheet1!$B$1)*(COUNTIF(B$1:B1,MasterList!$B$2:$B$10000)=0),),0)))

This makes your DropDownLists sheet look like this: 这使您的DropDownLists表如下所示:

DropDownLists示例

Lastly, we need to make that list (data based on the selected Data Option) a dynamic named range. 最后,我们需要使该列表(基于所选数据选项的数据)成为动态命名范围。 I named it listFilteredData and defined it with this formula: 我将其命名为listFilteredData ,并使用以下公式进行定义:

=DropDownLists!$B$2:INDEX(DropDownLists!$B:$B,MAX(2,ROWS(DropDownLists!$B:$B)-COUNTBLANK(DropDownLists!$B:$B)))

Then for Sheet1 cell B2, use Data Validation and define the list with =listFilteredData and you will get results as shown in my example. 然后,对于Sheet1单元格B2,使用数据验证并使用=listFilteredData定义列表,您将获得如我的示例所示的结果。

Practice with this.....it will get what you need. 练习吧.....它将满足您的需求。

Your data will have to sorted for this to work. 您的数据将必须排序才能正常工作。

Sorted Data 排序数据

排序数据

Data Validation for Shows 节目数据验证

在此处输入图片说明

在此处输入图片说明

Data Validation for Episodes 剧集的数据验证

This formula in the data validation box 数据验证框中的此公式

=OFFSET($A$1,MATCH($E$4,$A:$A,0)-1,1,COUNTIF($A:$A,$E$4),1)

在此处输入图片说明

在此处输入图片说明

Enter the array formula to find the Duration Must be confirmed with Ctrl & Shift & Enter 输入数组公式以找到持续时间,必须通过Ctrl&Shift&Enter确认

=INDEX($C$4:$C$18,MATCH(1,(E4=$A$4:$A$18)*(F4=$B$4:$B$18),0)) 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM