2

I have a minor problem while playing with Excel. Here is the problem definition:

I want conditional data validation for below table:

Column 1  Column 2
Y         Res1
Y         Res2
N         Res3
N         Res4
Y         Res5

From above table, I need a cell dropdown(using data validation) with the list of values from Column 2 who has 'Y' value in Column 1. Is it possible? If yes, could you please help me out. Your help will be appreciated.

Please note: I dont want to write Excel VBA for that, through VBA I am able to do so.. But requirement is to do with formulas.

2 Answers 2

1

Just use this array formula, and then copy down:

=INDEX($B$1:$B$5;SMALL(IF($A$1:$A$5="Y";ROW($A$1:$A$5)-ROW($A$1)+1;"");ROWS($A$1:A1)))

Dont forget to Ctrl Shift Enter

So change the formula to

=IFERROR(INDEX($B$1:$B$5;SMALL(IF($A$1:$A$5="Y";ROW($A$1:$A$5)-ROW($A$1)+1;"");ROWS($A$1:A1)));"")

Imagine you're writing the formula in D1, copy down till the maximum possible matches (for instance D1:D100 and name this range myrange) copy till the end (till you got at least an empty cell). Now write this formula in Source for List DataValidation:

=OFFSET(D1;0;0;MATCH("";myrange;0)-1;1)
Sign up to request clarification or add additional context in comments.

5 Comments

Yeah I have that formula, but my final output should be in Drop Down, which I am not able to do that... Thats why I have used Data Validation keyword. And even If, I use this formula in Name List, still I am not getting in that dropdown, since it's an array formula, while Data validation needs a list... Anyway Thanks for answer :)
So I think you should explain better when you're asking a question... :)
Hello, Thanks a lot... :) But seems that your second formula is not working, it will give same value for each of 100 cells.. Anyway that I have taken care of by changing a bit in formula: =IFERROR(INDEX($B$1:$B$5,SMALL(IF($A$1:$A$5="Y",ROW($A$1:$A$5),""),ROW())),"")... After that I used ur 3rd formula and it works... Thanks again... :)
I have just replaced ROWS($A$1:A1) with Row(), because when I use your array formula, for all 100 cells, it will take same value as ROWS($A$1:A1) is not getting incremented.
It should work, it is an array formula but it's only to use in one cell, then copy down for the others. Tried just now it works. But, the important part, you solve your problem.... :)
1

Thanks CRondao and Fagun...

Here is the final answer, I am writing in separate, as there is already more debate happened. So user, without wasting time in reading comments, can directly come here, and read answer...

Select 100 or more rows, press F2, and enter below formula,

=IFERROR(INDEX($B$1:$B$5,SMALL(IF($A$1:$A$5="Y",ROW($A$1:$A$5),""),ROW())),"")

And then press "Ctrl+Shift+Enter". Define name of range from Name manager with myrange for 100 or more cells.

Select E1 cell, and in Data validation write below formula for List:

=OFFSET(D1;0;0;MATCH("";myrange;0)-1;1)

1 Comment

This is a great help. The only thing that I would change is get rid of the IFERROR. There are some times that you will have to use IFERROR, but it has to calculate for each cell. Use a helper cell with the number of items to return, and use IF(CHECK>helpercell, "", formulaFromAnswer). This will speed up the calculation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.