Trying to simplify IF AND Statement

blittenb

New Member
Joined
Jul 26, 2023
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am trying to conditionally format based on the following requirements.

I am trying to accomplish the following:
If C8 = 0 then SUM(C21:C23) must = 0

If C8 = 1 then SUM(C21:C23) must = 0


If C8 = 2 then SUM(C21:C23) must = 2
If C8 = 3 then SUM(C21:C23) must = 4
etc

I came up with this but I feel this is granularity is unnecessary.
=IF(AND(C8=0,SUM(C21:C23)=0),TRUE,FALSE)
=IF(AND(C8=1,SUM(C21:C23)=0),TRUE,FALSE)
=IF(AND(C8=2,SUM(C21:C23)=2),TRUE,FALSE)
=IF(AND(C8=3,SUM(C21:C23)=4),TRUE,FALSE)


Nordstrom - LR Survey - Template.xlsx
BCDEF
8-12000
900000
1000000
1100000
1200000
1300000
1400000
1500000
1644000
1700000
1820000
1900000
2000000
2100000
2200000
2300000
NSG Engineer
Cell Formulas
RangeFormula
C8C8='LR BOM'!B84
D8D8='LR BOM'!B127
E8E8='LR BOM'!B169
F8F8='LR BOM'!B214
C9C9='LR BOM'!$B$69+'LR BOM'!$B$73+'LR BOM'!$B$77+'LR BOM'!$B$81
D9D9='LR BOM'!B112+'LR BOM'!B116+'LR BOM'!B120+'LR BOM'!B124
E9E9='LR BOM'!B154+'LR BOM'!B158+'LR BOM'!B162+'LR BOM'!B166
F9F9='LR BOM'!B199+'LR BOM'!B203+'LR BOM'!B207+'LR BOM'!B211
C10C10='LR BOM'!$B$83
D10D10='LR BOM'!B126
E10E10='LR BOM'!B168
F10F10='LR BOM'!B213
C11:C14C11=$C$10
D11:F11D11=D10
D12:F12D12=D10
D13:F13D13=D10
D14:F14D14=D10
C16:F16C16=2*C8-C17-C15
B8B8='LR BOM'!$B$42-1
B9B9=('LR BOM'!$B$27+'LR BOM'!$B$31+'LR BOM'!$B$35+'LR BOM'!$B$39)
B10B10='LR BOM'!B41
B11:B14B11=$B$10
B15:B17B15=(0+C15+D15+E15+F15)
B18B18=2
B19B19=$B$10-B20
C19C19=$C$10-C20
D19:F19D19=D10-D20
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F8Expression=SUM(F21:F23)<>(F8*1)textNO
F8Expression=SUM(F21:F23)=(F8*1)textNO
D8Expression=SUM(D21:D23)<>(D8*1)textNO
D8Expression=SUM(D21:D23)=(D8*1)textNO
E8Expression=SUM(E21:E23)<>(E8*1)textNO
E8Expression=SUM(E21:E23)=(E8*1)textNO
C8Expression=SUM(C21:C23)<>(C8*1)textNO
C8Expression=SUM(C21:C23)=(C8*1)textNO
B8Expression=IF(B8>(B21+B22+B23),"true","false")textNO
B8Expression=SUM(B21:B23)=(B8*2)textNO
B8Expression=SUM(B21:B23)<>(B8*2)textNO
B15,B16:F16,B17Cell Value>4textNO
B21Expression=SUM(B21:B23)<>(B8*2)textNO
B21Expression=SUM(B21:B23)=(B8*2)textNO
B22Expression=SUM(B21:B23)<>(B8*2)textNO
B22Expression=SUM(B21:B23)=(B8*2)textNO
B23Expression=SUM(B21:B23)<>(B8*2)textYES
B23Expression=SUM(B21:B23)=(B8*2)textNO
B10Cell Value<>$D$28textNO
B10Cell Value=$D$28textNO
C10Cell Value=$D$29textNO
C10Cell Value<>$D$29textNO
D10Cell Value<>$D$30textNO
D10Cell Value=$D$30textNO
E10Cell Value<>$D$31textNO
E10Cell Value=$D$31textNO
F10Cell Value<>$D$32textNO
F10Cell Value=$D$32textNO
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You can simplify these:
=IF(AND(C8=0,SUM(C21:C23)=0),TRUE,FALSE)
=IF(AND(C8=1,SUM(C21:C23)=0),TRUE,FALSE)
=IF(AND(C8=2,SUM(C21:C23)=2),TRUE,FALSE)
=IF(AND(C8=3,SUM(C21:C23)=4),TRUE,FALSE)

to this, since AND already returns a boolean value:
=AND(C8=0,SUM(C21:C23)=0)
=AND(C8=1,SUM(C21:C23)=0)
=AND(C8=2,SUM(C21:C23)=2)
=AND(C8=3,SUM(C21:C23)=4)
 
Upvote 0
You can simplify these:
=IF(AND(C8=0,SUM(C21:C23)=0),TRUE,FALSE)
=IF(AND(C8=1,SUM(C21:C23)=0),TRUE,FALSE)
=IF(AND(C8=2,SUM(C21:C23)=2),TRUE,FALSE)
=IF(AND(C8=3,SUM(C21:C23)=4),TRUE,FALSE)

to this, since AND already returns a boolean value:
=AND(C8=0,SUM(C21:C23)=0)
=AND(C8=1,SUM(C21:C23)=0)
=AND(C8=2,SUM(C21:C23)=2)
=AND(C8=3,SUM(C21:C23)=4)
I combined them to further simplify but thank you.

=AND(C8=2,SUM(C21:C23)=2)=AND(C8=1,SUM(C21:C23)=0)=AND(C8=0,SUM(C21:C23)=0)
 
Upvote 0
I don't think that formula works right. Try the E21 formula here:

Book1
CDE
83
9
10
11
12
13
14
15
16
17
18
19
20
210TRUE
222FALSE
232
Sheet2
Cell Formulas
RangeFormula
E21E21=LET(s,SUM(C21:C23),SWITCH(C8,0,s=0,1,s=0,2,s=2,3,s=4,FALSE))
E22E22=AND(C8=2,SUM(C21:C23)=2)=AND(C8=1,SUM(C21:C23)=0)=AND(C8=0,SUM(C21:C23)=0)
 
Upvote 1
Solution

Forum statistics

Threads
1,215,148
Messages
6,123,301
Members
449,095
Latest member
Chestertim

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