if statement - testing a single cell works, testing a range of cells not working

jgold20

Board Regular
Joined
Feb 4, 2018
Messages
135
The below works:

=IF(OR(I10>H10,I11>H11,I12>H12,I13>H13,I14>H14)," Discount Given is greater then Max. Discount",
IF(OR(C3={"B","W"}),"Discount can be UP to 7.5 %",
IF(OR(C3={"L","N"}),"Disc. Max. 3%/Midwest only - up to 7.5 %",
IF(OR(C3={"D","V","X","SR"}),"ENTER xx for MAX. DISCOUNT",""))))

When are try and do a range, I get a value error:

=IF(OR(I10>H10,I11>H11,I12>H12,I13>H13,I14>H14)," Discount Given is greater then Max. Discount",
IF(OR(C3:C7={"B","W"}),"Discount can be UP to 7.5 %",
IF(OR(C3={"L","N"}),"Disc. Max. 3%/Midwest only - up to 7.5 %",
IF(OR(C3={"D","V","X","SR"}),"ENTER xx for MAX. DISCOUNT",""))))
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try using instead...

Code:
=IF(OR(COUNTIF(C3:C7,"B")>0,COUNTIF(C3:C7,"W")>0)
 
Upvote 0
You need to do the OR test for each cell in the range. Assuming if any of C3:C7 is "B" or "W" you want the discount to be up to 7.5%, here's an alternative:
Code:
IF(SUMPRODUCT((C3:C7="B")+(C3:C7="W"))>0,"Discount can be UP to 7.5 %", ...
 
Upvote 0
Hi,

Try this:

=IF(OR(I10>H10,I11>H11,I12>H12,I13>H13,I14>H14),"Discount Given is greater then Max. Discount",IF(SUM(COUNTIF(C3:C7,{"B","W"})),"Discount can be UP to 7.5 %",IF(OR(C3={"L","N"}),"Disc. Max. 3%/Midwest only - up to 7.5 %",IF(OR(C3={"D","V","X","SR"}),"ENTER xx for MAX. DISCOUNT",""))))
 
Upvote 0
Problem just got a little more complicated. I have to possible handle all in the same way and a possible combination of all of them together plus 2 more combinations - if they exist with a different value in C3:C7 or if they do not exist at all but the different value does.


=IF(OR(I10>H10,I11>H11,I12>H12,I13>H13,I14>H14)," Discount Given is greater then Max. Discount",
IF(OR(C3:C7={"B","W"}),"Discount can be UP to 7.5 %",
IF(OR(C3:C7={"L","N"}),"Disc. Max. 3%/Midwest only - up to 7.5 %",
IF(OR(C3:C7={"D","V","X","SR"}),"ENTER xx for MAX. DISCOUNT",
IF(OR(C3:C7={"B","W""D","L","N"}),"Discount can be UP to 7.5 %",
IF(OR(C3:C7={"H","GE"}),"Max discount is 5%",
IF(OR(C3:C7={"B","W""D","V","X","SR"}),"Discount can be UP to 7.5 %/ENTER xx for MAX. DISCOUNT","")))).
ETC
 
Upvote 0
wonder if you might better off with a table, where B =1, D =2, etc then reffering to the table
OR
maybe a select case statement in VBA might be a better option ????


BUT, we would need to know every single variable in the equation !
 
Last edited:
Upvote 0
The below is working EXCEPT if I have something else (C3=H,"MAX % is 5%", etc.) along with any of the other combinations:

=IF(OR(I10>H10,I11>H11,I12>H12,I13>H13,I14>H14)," Discount Given is greater then Max. Discount - CALL LISA OR JOE",
IF(SUMPRODUCT((C3:C7="B")+(C3:C7="W"))>0,"Discount can be UP to 7.5 %",
IF(SUMPRODUCT((C3:C7="L")+(C3:C7="N"))>0,"Disc. Max. 3%/Midwest only - up to 7.5 %",
IF(SUMPRODUCT((C3:C7="B")+(C3:C7="W")+(C3:C7="L")+(C3:C7="N"))>0,"Discount can be UP to 7.5 %",
IF(SUMPRODUCT((C3:C7="D")+(C3:C7="V")+(C3:C7="X")+(C3:C7="SR"))>0,"ENTER CF for MAX. DISCOUNT",
IF(SUMPRODUCT((C3:C7="L")+(C3:C7="N")+(C3:C7="D")+(C3:C7="V")+(C3:C7="X")+(C3:C7="SR"))>0,"Discount can be UP to 7.5 %/ENTER CF for MAX. DISCOUNT",
IF(SUMPRODUCT((C3:C7="B")+(C3:C7="W")+(C3:C7="L")+(C3:C7="N")+(C3:C7="D")+(C3:C7="V")+(C3:C7="X")+(C3:C7="SR"))=0,"Max % is 5%",)))))))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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