SOLVED

help with formula

Copper Contributor

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?

7 Replies

@JohnShaw19 

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,"")

@JohnShaw19 

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.

S1413.png

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],"")

@Hans Vogelaar 

 

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:

 

Screenshot 2022-05-07 163802.jpg

@JohnShaw19 

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.

sure! There's no sensitive data. Just working out the basic spreadsheet.
https://1drv.ms/x/s!Ag5CIttUj0lyiolPe-WH_GyAh0ZDcg?e=76Ftg0
best response confirmed by JohnShaw19 (Copper Contributor)
Solution

@JohnShaw19 

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.

That was it!!! Thanks so much! I honestly do not remember putting data values in D2. So much appreciate your help.
1 best response

Accepted Solutions
best response confirmed by JohnShaw19 (Copper Contributor)
Solution

@JohnShaw19 

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.

View solution in original post