SOLVED

Using named range with FILTER function in data validation list (dynamic dropdown)

%3CLINGO-SUB%20id%3D%22lingo-sub-2011307%22%20slang%3D%22en-US%22%3EUsing%20named%20range%20with%20FILTER%20function%20in%20data%20validation%20list%20(dynamic%20dropdown)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2011307%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20use%20a%20named%20range%20as%20a%20data%20validation%20list%20but%20unsuccessfull%20do%20far.%20The%20named%20range%20is%20created%20using%20Excel's%20Name%20manager%20under%20Formulas%20Tab.%20The%20named%20range%20has%20a%20formula%20that%20filters%20a%20specific%20column%20of%20a%20table%20based%20on%20two%20criteria%20(AND%20condition).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20main%20table%20called%20%22Employees%22%20(see%20tblEmployees.jpg).%20It%20is%20located%20in%20a%20sheet%20called%20%22List%20of%20Employees%22%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22tblEmployees.JPG%22%20style%3D%22width%3A%20612px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F242444i7443A273781A53BF%2Fimage-dimensions%2F612x229%3Fv%3D1.0%22%20width%3D%22612%22%20height%3D%22229%22%20role%3D%22button%22%20title%3D%22tblEmployees.JPG%22%20alt%3D%22tblEmployees.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIn%20another%20sheet%20called%20%22Employee%20Leave%20Tracker%22%2C%20I%20have%20a%20table%20called%20%22Leave%20Tracker%22.%20The%20structure%20of%20the%20table%20is%20shown%20in%20image%20tblLeaveTracker.jpg%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22tblLeaveTracker.JPG%22%20style%3D%22width%3A%20613px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F242447i1B2DDB5F10329EAF%2Fimage-dimensions%2F613x226%3Fv%3D1.0%22%20width%3D%22613%22%20height%3D%22226%22%20role%3D%22button%22%20title%3D%22tblLeaveTracker.JPG%22%20alt%3D%22tblLeaveTracker.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20user%20selects%20%22Unit%22%20and%20%22Area%22%20(dropdowns%20using%20data%20list%20validation%20are%20already%20created)%2C%20but%20in%20the%20thrird%20column%20(Employee%20Name)%2C%20I%20want%20to%20display%20only%20the%20list%20of%20employees%20that%20belong%20to%20specific%20Unit%20and%20Area%20selected%20in%20the%20first%20and%20second%20column.%20For%20this%2C%20I%20used%20a%20simple%20filter%20function%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EFILTER(Employees%5BEmployee%20Names%5D%2C(Employees%5BUnit%5D%3DLeaveTracker%5B%40Unit%5D)*(Employees%5BArea%5D%3DLeaveTracker%5B%40Area%5D)%2C%22Not%20Found%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20formula%20works%20just%20fine.%20I%20can%20see%20the%20correct%20results%20when%20I%20use%20this%20formula%20in%20a%20cell%20outside%20the%20table.%20However%2C%20I%20want%20the%20dropdown%20in%20the%20third%20column%20(Employee%20Name)%20to%20be%20dynamic%20based%20on%20selection%20in%20the%20first%20two%20columns%2C%20so%20I%20thought%20of%20creating%20a%20named%20range%20using%20the%20above%20%22FILTER%22%20formula.%20I%20created%20a%20named%20range%20called%20%22lstEmpNameDynamic%22.%20(see%20Named_Range.jpg)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Named_Range.JPG%22%20style%3D%22width%3A%20663px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F242448iEF3462D8214A0224%2Fimage-dimensions%2F663x186%3Fv%3D1.0%22%20width%3D%22663%22%20height%3D%22186%22%20role%3D%22button%22%20title%3D%22Named_Range.JPG%22%20alt%3D%22Named_Range.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20When%20i%20try%20to%20use%20this%20named%20range%20in%20the%20Data%20Validation%20List%20source%2C%20I%20get%20an%20error%20(see%20Error.jpg)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22DataVal.JPG%22%20style%3D%22width%3A%20537px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F242450i9552C4E86D9FEB62%2Fimage-dimensions%2F537x493%3Fv%3D1.0%22%20width%3D%22537%22%20height%3D%22493%22%20role%3D%22button%22%20title%3D%22DataVal.JPG%22%20alt%3D%22DataVal.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Error.JPG%22%20style%3D%22width%3A%20530px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F242451i073FBFDA2B44878A%2Fimage-dimensions%2F530x172%3Fv%3D1.0%22%20width%3D%22530%22%20height%3D%22172%22%20role%3D%22button%22%20title%3D%22Error.JPG%22%20alt%3D%22Error.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20I%20solve%20this%3F%20I%20need%20the%20dynamic%20dropdown%20to%20work%20for%20each%20row%20of%20the%20Leave%20Tracker%20table.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2011307%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2012734%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20named%20range%20with%20FILTER%20function%20in%20data%20validation%20list%20(dynamic%20dropdown)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2012734%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3BI%20tried%20this%20method%2C%20but%20it%20only%20works%20for%20single%20row.%20If%20you%20look%20at%20my%20table%20%22Leave%20Tracker%22%2C%20I%20need%20the%20dynamic%20drop%20down%20to%20work%20for%20all%20rows%20of%20the%20table.%20Unfortunately%2C%20the%20dropdown%20for%20%22Employee%20Name%22%20column%20for%20rows%202%20and%20beyond%20wont%20change%20irrespective%20of%20selections%20in%20%22Unit%22%20and%20%22Area%22%20columns.%20Only%20the%20first%20row%20is%20functional.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20suggestions%20on%20how%20this%20can%20be%20implemented%20to%20multiple%20rows%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2012825%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20named%20range%20with%20FILTER%20function%20in%20data%20validation%20list%20(dynamic%20dropdown)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2012825%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F909936%22%20target%3D%22_blank%22%3E%40RockB115%3C%2FA%3E%26nbsp%3BPerhaps%20easier%20to%20help%20if%20you%20upload%20your%20file.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2012863%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20named%20range%20with%20FILTER%20function%20in%20data%20validation%20list%20(dynamic%20dropdown)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2012863%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F909936%22%20target%3D%22_blank%22%3E%40RockB115%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDrop-down%20list%20works%20with%20ranges%2C%20not%20with%20arrays.%20First%20in%20mind%20is%20to%20create%20such%20helper%20range%20somewhere%20outside%20-%20spill%20two%20columns%20from%20the%20table%2C%20add%20transpose%20filters%20to%20each%20row%20and%20INDEX()%23%20them%20in%20drop-down%20list.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2012975%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20named%20range%20with%20FILTER%20function%20in%20data%20validation%20list%20(dynamic%20dropdown)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2012975%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BBut%20does%20this%20work%20for%20multiple%20rows%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello,

 

I am trying to use a named range as a data validation list but unsuccessfull do far. The named range is created using Excel's Name manager under Formulas Tab. The named range has a formula that filters a specific column of a table based on two criteria (AND condition).

 

Here is the main table called "Employees" (see tblEmployees.jpg). It is located in a sheet called "List of Employees"

tblEmployees.JPG

In another sheet called "Employee Leave Tracker", I have a table called "Leave Tracker". The structure of the table is shown in image tblLeaveTracker.jpg

tblLeaveTracker.JPG

 

The user selects "Unit" and "Area" (dropdowns using data list validation are already created), but in the thrird column (Employee Name), I want to display only the list of employees that belong to specific Unit and Area selected in the first and second column. For this, I used a simple filter function:

 

FILTER(Employees[Employee Names],(Employees[Unit]=LeaveTracker[@Unit])*(Employees[Area]=LeaveTracker[@Area]),"Not Found")

 

 

This formula works just fine. I can see the correct results when I use this formula in a cell outside the table. However, I want the dropdown in the third column (Employee Name) to be dynamic based on selection in the first two columns, so I thought of creating a named range using the above "FILTER" formula. I created a named range called "lstEmpNameDynamic". (see Named_Range.jpg)

 

Named_Range.JPG

 

However, When i try to use this named range in the Data Validation List source, I get an error (see Error.jpg)

 

DataVal.JPG

 

Error.JPG

 

How can I solve this? I need the dynamic dropdown to work for each row of the Leave Tracker table.

9 Replies

@RockB115 Lists in data validation need to refer to named ranges. You created a named formula.

 

Put your FILTER formula in an area outside the view of your work. For example in cell AA1. The FILTER function will spill the matching Employee names to cell AA1 and down.

 

Now, you can point data validation to =$AA$1#

Screenshot 2020-12-23 at 07.12.26.png

 

The # sign tells Excel to take the entire spilled range starting in AA1. Perhaps only one row or sometimes ten rows. Or nothing at all. Depending on the FILTER outcome.

@Riny_van_Eekelen I tried this method, but it only works for single row. If you look at my table "Leave Tracker", I need the dynamic drop down to work for all rows of the table. Unfortunately, the dropdown for "Employee Name" column for rows 2 and beyond wont change irrespective of selections in "Unit" and "Area" columns. Only the first row is functional.

 

Any suggestions on how this can be implemented to multiple rows?

@RockB115 Perhaps easier to help if you upload your file.

@RockB115 

Drop-down list works with ranges, not with arrays. First in mind is to create such helper range somewhere outside - spill two columns from the table, add transpose filters to each row and INDEX()# them in drop-down list.

@Riny_van_Eekelen Here is the link to the file: EATT_Test.xlsx 

Take a look at the sheet "Employee Leave Tracker". There is a table called "Leave Tracker". I want all the rows of the table to have dynamic filtered dropdown for column "Employee Names". User selects values in first two columns "Unit" and "Area". The dropdown in the third column (Employee Names) should have a dynamic dropdown based on values selected in the previous two columns and this should work for all rows of the table.

 

The master data for all the filtering is located in the sheet "List of Employees" in a table called "Employees"


I was only able to get it working for only one row of the table.

best response confirmed by RockB115 (Occasional Contributor)
Solution

@RockB115 

That's small sample file

image.png

Helper range expands automatically if you change the table except spills in column N shall be drag down. Data validation formula is

=XLOOKUP($H4&$I4,$L$9:L10&$M$9:$M10,$N$9:$N10)#

It is expandable if take care about absolute/relative references.

Just mock-up, perhaps it could be done more elegant.

 

@Sergei Baklan Thanks! This solution works. I was looking to avoid VBA since I was planning to upload this file to Onedrive and use Excel Online. This solution just made this possible. 

 

One very small correction in your XLOOKUP formula was to change "L10 to $L10"

 

Also, the helper table 

=Table2[[Unit]:[Area]]

is dynamic but the FILTER formula on the adjacent cell (N9) didn't update as size of helper table increased.

=TRANSPOSE(FILTER(Table1[Name],(Table1[Unit]=L9)*(Table1[Area]=M9)))

 

However, it was an easy fix. I just dragged down the formula to fill the entire N column. I suspect this somehow made my excel workbook slower. Saving takes a little more time now. But should be OK and everything works as excepted. Thanks Again!

 

@RockB115 

Yes, FILTER() shall be dragged down if the table is expanded. On the other hand you may drag it with some gap from very beginning. Filter against empty columns shall return an error, I guess CALC. You may wrap formula with IFERROR or simply ignore errors, in helper sheet they affect nothing.

 

Performance - I don't think it'll be significant impact, approximately the same as you add one more calculated column into your main table.