Excel Index Dynamic List based on cell criteria

ManUBlueJay

Active Member
Joined
Aug 30, 2012
Messages
326
Office Version
  1. 365
Platform
  1. Windows
I am looking to create a named range list to be used in Data Validation dropdown.

Contractor type choice is in L10.
Baes on this I want it to return all contractors who are Architects or whatever is chosen in L10.
I tried this which works for the single ones but not when the list is greater than 1
=INDEX(TableContractors,MATCH($L$10,TableContractors[Contractor Type],0),1,COUNTIF(TableContractors[Contractor Type],'$L$10))
The 2 col table is called TableContractors
Excel1.jpg

Any Help would be appreciated
 

Attachments

  • Excel1.jpg
    Excel1.jpg
    16.7 KB · Views: 6

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try using OFFSET instead of INDEX:

Excel Formula:
=OFFSET(TableContractors[Contractor List],MATCH($L$10,TableContractors[Contractor Type],0)-1,0,COUNTIF(TableContractors[Contractor Type],$L$10))

If you don't want to use OFFSET, try INDEX:INDEX instead:

Excel Formula:
=INDEX(TableContractors,MATCH($L$10,TableContractors[Contractor Type],0),1):INDEX(TableContractors,MATCH($L$10,TableContractors[Contractor Type],0)+COUNTIF(TableContractors[Contractor Type],$L$10)-1,1)

Please note, structured Excel table references cannot be used directly within Data Validation; however, you can define custom names in Name Manager that reference the applicable table/columns, then reference those defined names in the Data Validation list source.

Also, it's important to note that your table in this example must always be sorted by Contractor Type in order to return the correct Contractor List.
 
Upvote 0
@djclements
Don't both of your formula suggestions rely on the ability of the formula results to spill, noting that the OPs version indicates they do not have that feature?

Please note, structured Excel table references cannot be used directly within Data Validation; ..
Unless I am misunderstanding what you are saying, they can be used directly, with INDIRECT (if that is not a contradiction), in data validation without doing anything manually in Name Manager.
For example if DV list of Contractors was required

ManUBlueJay.xlsm
KL
1
2Contractor ListContractor Type
3Cont 1Architect
4Cont 6Consultancy
5Cont 3Architect
6Cont 2Contractor Type
7Cont 5Engineer
8
11
12Contractor
Sheet3
Cells with Data Validation
CellAllowCriteria
L12List=INDIRECT("TableContractors[Contractor List]")


1725239202953.png


@ManUBlueJay
I am not sure how you have set up your Contractor Type DV in L10 but if you are then looking to have a DV list of contractors based on the type chosen and you are still using Excel 2016 then here is one way (& sorting is not relevant). The helper column can be hidden.

ManUBlueJay.xlsm
KLMN
1$N$2:$N$3
2Contractor ListContractor TypeCont 1
3Cont 1ArchitectCont 3
4Cont 6Consultancy 
5Cont 3Architect 
6Cont 2Contractor Type 
7Cont 5Engineer 
8
9
10Contractor TypeArchitect
11
12Contractor
13
Sheet1
Cell Formulas
RangeFormula
N1N1=ADDRESS(ROW(N2),COLUMN())&":"&ADDRESS(COUNTIF(N2:N7,"?*")+ROW(N2)-1,COLUMN())
N2:N7N2=IFERROR(INDEX(TableContractors[Contractor List],AGGREGATE(15,6,(ROW(TableContractors[Contractor List])-ROW(TableContractors[#Headers]))/(TableContractors[Contractor Type]=L$10),ROWS(N$2:N2))),"")
Cells with Data Validation
CellAllowCriteria
L12List=INDIRECT($N$1)


1725239556866.png
 
Upvote 0
Don't both of your formula suggestions rely on the ability of the formula results to spill, noting that the OPs version indicates they do not have that feature?

Unless I am misunderstanding what you are saying, they can be used directly, with INDIRECT (if that is not a contradiction), in data validation without doing anything manually in Name Manager.

Both of my suggested formulas will work in older versions of Excel (tested and confirmed with Excel 2010), so long as they're defined in Name Manager or used directly in Data Validation (without directly referencing the structured table names).

As you've pointed out, the INDIRECT function can be used as a workaround; however, I wouldn't recommend it because the Data Validation list source is limited to 255 total characters. With lengthy table/column names, the formula can easily end up exceeded the character limit. For example, the INDEX:INDEX variant would be 261 characters long when all of the necessary INDIRECT functions are added.

There's two ways I would recommend implementing my suggested formulas:

Option 1: If L10 is the only cell in the workbook where the Contractor Type is selected, then you can define a dynamic named range in Name Manger using the entire formula. For example, lstContractors could be defined as follows:

Excel Formula:
=OFFSET(TableContractors[Contractor List],MATCH(Sheet1!$L$10,TableContractors[Contractor Type],0)-1,0,COUNTIF(TableContractors[Contractor Type],Sheet1!$L$10))

NOTE: adjust the sheet name (Sheet1) as needed.

Then, use =lstContractors as the dependent Data Validation list source.

Option 2: If L10 is NOT the only parent cell in the workbook (e.g. if you need to have dependent data validation functionality for every row in a table), I would first define two shorter/concise names in Name Manager for the necessary table columns. For example, ctrNames and ctrTypes could be defined as =TableContractors[Contractor List] and =TableContractors[Contractor Type] respectively.

Then, the following formula could be used directly as the Data Validation list source:

Excel Formula:
=OFFSET(ctrNames,MATCH($L10,ctrTypes,0)-1,0,COUNTIF(ctrTypes,$L10))

This is what it looks like in Excel 2010:

dynamic_named_range_2010.png

dependent_dv_lists_2010.png


I hope that clears things up. Cheers!
 
Upvote 0
Both of my suggested formulas will work in older versions of Excel (tested and confirmed with Excel 2010), so long as they're defined in Name Manager
:oops: Ah, re-reading posts 1 & 2 together I realise that I had not interpreted your suggestion correctly.
 
Upvote 0

Forum statistics

Threads
1,224,808
Messages
6,181,073
Members
453,020
Latest member
mattg2448

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top