简体   繁体   中英

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

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. I have a list of about 400 different account names. Each of these account names is tied to a household and identified by the household ID number. A household can have anywhere from 1-5 account names. 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.

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.

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. 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:

Sheet1示例

On your second sheet, which we'll call MasterList , is all of the data options and the corresponding data. Row 1 is a header row; Row 2 and down is the actual data:

MasterList示例

On your third sheet, which we'll call DropDownLists , is where the magic happens. 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). That list of unique data options is the basis of your drop down list for Sheet1 cell 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):

=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示例

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:

=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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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