Excel 2013 Formula IF with AND, OR, and NOT, or may conditional formatting

BGDunbar

Board Regular
Joined
Jul 26, 2016
Messages
79
I understand how to use a nested IF statement in Excel and I understand how to use one of the three conditions (AND, OR, NOT) individually in a formula. What I want to do is:

If Cell AC15 is equal to 1 or 2 and Cell AD15 and AD16 are equal to 1, then "OK", If AC15 is equal to 3 and AD15 & 16 Equal 3 then OK, If AC15 is equal to 4 and AD15 & AD16 equal 4 then OK, If not then "ERROR"

Samples
AC15 = 1
AD15 = 1
AE15 = 1
OK

AC15 = 2
AD15 = 1
AE15 = 1
OK

These are the only two with a second condition being that AC15 can either be 1 or 2 as long as the other two are 1, not 2.

AC15 = 3
AD15 = 2
AE15 = 3
ERROR

AC15 = 1
AD15 = 3
AE15 = 1
ERROR

The remaining conditions are all three must begin with the same number.

I need some way for these situations to POP OUT at me so I know something is wrong with my coding.

Any help is greatly appreciated.

Betty


EDIT:
Another way to look at it is our financial coding has a 5 digit Index, a 5 digit PCA, and a 5 Digit Appn No. The rule is that if the Index begins with 1 or 2 the PCA must start with 1 AND the 3rd Digit of the PCA must be 1. If the Index begins with 3 or 4 then the first digit of the PCA AND the third digit of the Appn No also have to be 3. I have formulas pulling the respective digits out of the 5 digits but I'm not sure if that is the best way to start..

HELP!

Thanks,
 
Last edited by a moderator:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi,

Based on your description before your EDIT info, and assuming when you say AD16, you actually mean AE15:


Book1
ACADAEAFAG
15111OK
16211OK
17323ERROR
18131ERROR
19333OK
20334ERROR
21444OK
22423ERROR
Sheet1
Cell Formulas
RangeFormula
AG15=IF(OR(AND(OR(AC15={1,2}),AD15=1,AE15=1),COUNTIF(AC15:AE15,{3,4})=3),"OK","ERROR")
 
Last edited:
Upvote 0
Hi,

Also, if you prefer to use Conditional Formatting, then use this formula for CF:


Book1
ACADAEAFAG
15111TRUE
16211TRUE
17323FALSE
18131FALSE
19333TRUE
20334FALSE
21444TRUE
22423FALSE
Sheet1
Cell Formulas
RangeFormula
AG15=OR(AND(OR(AC15={1,2}),AD15=1,AE15=1),COUNTIF(AC15:AE15,{3,4})=3)


Just wrap the formula with NOT to reverse the logic.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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