Forum Discussion
help with formula
I am sorry if this is simple but I just cannot figure it out. I have a drop down data column with three sizes, 4x6, 5x7, and 9x4 in column A. in column D my heading is "cards per sheet". If I select "4x6" it should say"20" in column D. If "5x7" - "16", and if "9x4" - "15".
I cannot figure out how to use an IF statement to return those values. What can I do?
I forgot 2 closing parentheses - sorry about that. The first formula should be
=IF(A2="4x6",20,IF(A2="5x7",16,IF(A2="9x4",15,"")))
But you have set up date validation for D2 that only allows the values 1, 2, ..., 10. So 20, 16 and 15 will be rejected.
I'd remove the data validation from D2. If you use a formula, data validation is not needed.
7 Replies
Or use a lookup table. The first column can be the source for the data validation drop-down.
In the screenshot below, the table is named Sizes.
The formula in B2 (on your worksheet it would be D2) is
=IFERROR(VLOOKUP(A2,Sizes,2,FALSE),"")
If you have Microsoft 365 or Office 2021, you can also use
=XLOOKUP(A2,Sizes[Size],Sizes[Cards per Sheet],"")
- JohnShaw19Copper Contributor
Thanks for that info. So, in the first example I always get an error that says there was a typo in the formula, and it tries to correct it. But then I get an error that says, "The value doesn't match the data validation restrictions, defined by this cell."
In Column A2 I have a data validation criterion of, "list" and in the Source I have 4x6, 5x7, and 9x4. That creates the drop-down values in column A2. This is how the "form" looks:
Could you attach a sample workbook (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar? Thanks in advance.
Let's say the drop-downs are in A2 and below.
Enter the following formula in D2, then fill down:
=IF(A2="4x6",20,IF(A2="5x7",16,IF(A2="9x4",15,"")