Question : Using VLookup for Data Validation

I have defined several named ranges for data validation.
Is there a way to reference data validation in a VLookup statement?

For instance, If A2 is equal to “Smith” then the drop down box would contain a list of data from named range “Smith_Projects”
If A2 is equal to “Jones” then the same drop down box as specified in the first example would contain a list of data from named range “Jones_Projects”

Here is my current vlookup statement:
=IF(ISNA(VLOOKUP(A2,LookupTable!A2:N20,3,FALSE)),"", IF(VLOOKUP(A2, LookupTable!A2:N20, 3,FALSE)="","", VLOOKUP(A2,LookupTable!A2:N20,3,FALSE)))

Any help would be greatly appreciated.

Thank you
Diammond

Answer : Using VLookup for Data Validation

Diammond,
The following formula in the Source field for cell M2 data validation will give you the dropdowns you want without needing all the defined names on worksheet NSR or elimination of the spaces from the dropdown choices in cell A2:
=IF(ISNA(MATCH(A2,ColSource,0)),space,OFFSET(INDEX(ColSource,,MATCH(A2,ColSource,0)),1,0,COUNTA(OFFSET(INDEX(ColSource,,MATCH(A2,ColSource,0)),0,0,100,1)),1))

Towards the end of the above formula you will see 100 as the number of cells examined for possible dropdown values. This is an arbitrary value, and can exceed the maximum number of values you ever expect.

If you have no idea how many values you might expect, then you can use an additional named range ddSource in this data validation formula:
=IF(ISNA(MATCH(A2,ColSource,0)),space,OFFSET(INDEX(ColSource,,MATCH(A2,ColSource,0)),1,0,COUNTA(INDEX(ddSource,,MATCH(A2,ColSource,0))),1))
=NSR!$1:$65536               source for named range ddSource
This data validation is shown in cell M3. Note that you must use ddSource in the data validation because it refers to a different worksheet.

The sample file includes both data validation formulas (cells M2 and M3). It also eliminated the line feed character from cell O2 (used in named range space).

Brad

Random Solutions  
 
programming4us programming4us