Is it possible to use IF function inside the Conditional Formatting formula?

Sh8dyDan

New Member
Joined
Dec 20, 2023
Messages
25
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am working to create a 2-week timesheet for personal use to track hours and calculate pay to later compare to the actual pay stub. We have a non-rotating day shift and a rotating 12-hour shift. We have a list of observed holidays I'd like the row that a holiday falls on to have a colored background. The kicker is that non-rotating and rotating shift holidays can at times be observed on different days. I created two defined name lists for each shift with the dates of their holidays, HolidayNonRotation and HolidayRotating. I'd like to use a set of Radio Buttons "Non-Rotating Shift" and "Rotating Shift" to switch between formatting. I can not find a solution similar to my use or create one of my own that works.

I've tried the code below with no luck. When the formula is TRUE it always returns FALSE. Even when I change the state of the Radio Button. I have verified referenced cells are correct.

Excel Formula:
=IF(AB6=1,MATCH($Z6,HolidaysNonRotating,0),MATCH($Z6,HolidaysRotating,0)

TimesheetScreenshot01.jpg
TimesheetScreenshot02.jpg


Thank you in advance,
Dan N.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Check this and revert - Not sure it will work or not...

Excel Formula:
=And(AB6=1,MATCH($Z6,HolidaysNonRotating,0),MATCH($Z6,HolidaysRotating,0)
 
Upvote 0
This should work - Have to find way to bypass IF function

Excel Formula:
=OR(And(AB6=1,MATCH($Z6,HolidaysNonRotating,0)),And(AB6<>1,MATCH($Z6,HolidaysRotating,0)))
 
Upvote 0
This should work - Have to find way to bypass IF function

Excel Formula:
=OR(And(AB6=1,MATCH($Z6,HolidaysNonRotating,0)),And(AB6<>1,MATCH($Z6,HolidaysRotating,0)))
The formula logic appears to be good, but the highlights never change when changing the radio button.
 
Upvote 0
2023 Paycheck Calculator.xlsx
HIJKLMNOPQRSTUVWXYZAAAB
3 Hours WorkedDate Start
4Scheduled HoursHours WorkedWorked BreakEarly StartStraightOvertime 1.5Overtime 2.0Overtime 2.52nd Shift2rd Shift 1.52rd Shift 2.03rd Shift3rd Shift 1.53rd Shift 2.012/18/2023
56:30 AM4:30 PM1037.9756.9675.9494.930.200.300.400.400.600.80Total10 Hour / Shift
6M6:30 AM4:30 PM10.0010.00 1.50 0.50 380.2012/18/20231
7T6:30 AM4:30 PM10.0010.00 1.50 0.50 380.2012/19/2023
8W6:30 AM4:30 PM10.0010.00 1.50 0.50 380.2012/20/2023
9T6:30 AM4:30 PM10.0010.00 1.50 0.50 380.2012/21/2023
10F   -0.63  -0.1912/22/2023
11S        12/23/2023
12S           12/24/2023
13M6:30 AM4:30 PM10.0010.00 1.50 0.50 380.2012/25/2023
14T6:30 AM4:30 PM10.0010.00 1.50 0.50 380.2012/26/2023
15W6:30 AM4:30 PM10.0010.00 1.50 0.50 380.2012/27/2023
16T6:30 AM4:30 PM10.0010.00 1.50 0.50 380.2012/28/2023
17F       12/29/2023
18S       12/30/2023
19S          12/31/2023
203041.41
21Total HoursStraightOvertime 1.5Overtime 2.0Overtime 2.52nd Shift2rd Shift 1.52rd Shift 2.03rd Shift3rd Shift 1.53rd Shift 2.0
2280.0080.00   12.00-0.63 4.00  
23Straight PayOT 1.5 PayOT 2.0 PayOT 2.5 PayTotal Pay
243037.60   2.40-0.19 1.60  3041.41
NEW W-4
Cell Formulas
RangeFormula
O5O5=N5*1.5
P5P5=N5*2
Q5Q5=N5*2.5
N6:N9,N13:N16N6=IF(K6=0,,MIN($K$5,K6))
O6:O9,O13:O16O6=IF(K6=0,,IF(AND(K6>=$K$5,AE6=TRUE,AF6=TRUE), (K6-N6)+0.5+2, IF(AND(K6>=$K$5,AE6=TRUE,AF6=FALSE), (K6-N6)+0.5, IF(AND(K6>=$K$5,AE6=FALSE,AF6=TRUE), (K6-N6)+2, IF(AND(K6>=$K$5,AE6=FALSE,AF6=FALSE), K6-N6, IF(AND(K6<$K$5,AE6=TRUE,AF6=TRUE),2, IF(AND(K6<$K$5,AE6=TRUE,AF6=FALSE),, IF(AND(K6<$K$5,AE6=FALSE,AF6=TRUE),2,))))))))
N10,N17N10=IF(SUM(N6:N9)>=40,,IF(SUM(N6:N9)+K10<=40,IF(40-SUM(N6:N9)<$K$5,MIN($K$5,K10),K10),40-SUM(N6:N9)))
O10:O11,O17:O18O10=IF(K10=0,,IF(AND(K10>=$K$5,AE10=TRUE,AF10=TRUE),IF(K10<$K$5,,(K10-N10)+0.5+2),IF(AND(K10>=$K$5,AE10=TRUE,AF10=FALSE),IF(K10<$K$5,,(K10-N10)+0.5),IF(AND(K10>=$K$5,AE10=FALSE,AF10=TRUE),(K10-N10)+2,IF(AND(K10>=$K$5,AE10=FALSE,AF10=FALSE),K10-N10,IF(AND(K10<$K$5,AE10=TRUE,AF10=TRUE),(K10-N10)+2,IF(AND(K10<$K$5,AE10=TRUE,AF10=FALSE),(K10-N10),IF(AND(K10<$K$5,AE10=FALSE,AF10=TRUE),(K10-N10)+2,IF(AND(K10<$K$5,AE10=FALSE,AF10=FALSE),K10-N10)))))))))
N11,N18N11=IF(SUM(N6:N10)>=40,,IF(SUM(N6:N10)+K11<=40,IF(40-SUM(N6:N10)<$K$5,MIN($K$5,K11),K11),40-SUM(N6:N10)))
R6:R9,R13:R16R6=IF(J6>=$T$34,IF((J6-I6)*24>=$K$5,IF(I6+($K$5/24)<$T$34,,((I6+($K$5/24))-$T$34)*24),IF(J6>=$T$35,IF(I6>=$T$34,($T$35-I6)*24,($T$35-$T$34)*24),IF(I6>=$T$34,(J6-I6)*24,(J6-$T$34)*24))),)
S6:S9,S11,S13:S18S6=IF(J6>=$T$34,IF((J6-I6)*24>=$K$5,IF(I6+($K$5/24)<$T$34,IF(J6>=$T$35,($T$35-$T$34)*24,(J6-$T$34)*24),IF(J6>=$T$35,IF(I6>=$T$34,($T$35-I6)*24,($T$35-$T$34)*24),IF(I6>=$T$34,(J6-I6)*24,(J6-(I6+($K$5/24)))*24))),),)
R10R10=IF(SUM(N6:N9)>=40,,IF(SUM(N6:N9)+K10<40,IF(J10<$T$34,,IF(J10<T35,(J10-$T$34)*24,($T$35-$T$34)*24)),IF(I10+((40-SUM(N6:N9))/24)<$T$34,,IF(I10+((40-SUM(N6:N9))/24)<$T$35,((I10+((40-SUM(N6:N9))/24))-$T$34)*24,($T$35-$T$34)*24))))
S10S10=IF(I10+((40-SUM(N6:N9))/24)<S35, IF(I10+((40-SUM(N6:N9))/24)<S35, IF(I10+((40-SUM(N6:N9))/24)<T35, J10-S35, T35-S35),2222),1111)
R11,R18R11=IF(SUM(N6:N10)>=40,,IF(SUM(N6:N10)+K11<40,IF(J11<$T$34,,IF(J11<$T$35,(J11-$T$34)*24,($T$35-$T$34)*24)),IF(I11+((40-SUM(N6:N10))/24)<$T$34,,IF(I11+((40-SUM(N6:N10))/24)<$T$35,((I11+((40-SUM(N6:N10))/24))-$T$34)*24,$T$35-$T$34))))
U6:U9,U13:U16U6=IF(K6=0,,IF(OR(I6<$S$34,J6>=$S$36),IF(AND(I6<$S$34,J6>=$S$36),($S$34-I6)*24,IF(I6<$S$34,($S$34-I6)*24,IF((J6-I6)*24>=$K$5,IF(I6+($K$5/24)>$S$36,((I6+($K$5/24))-$S$36)*24,),(J6-$S$36)*24))),))
V6:V11,V13:V18V6=IF(K6=0,,IF(OR(I6<$S$34,J6>=$S$36),IF(AND(I6<$S$34,J6>=$S$36),(($T$36-I6)+(J6-$S$36))*24,IF(I6<$S$34,,IF((J6-I6)*24>=$K$5,IF(I6+($K$5/24)>$S$36,((I6+($K$5/24))-$S$36)*24,(J6-$S$36)*24),(J6-$S$36)*24))),))
U10,U17U10=IF(SUM(N6:N9)>=40,,IF(K10=0,,IF(OR(I10<$S$34,J10>=$S$36),IF(AND(I10<$S$34,J10>=$S$36),($S$34-I10)*24,IF(I10<$S$34,($S$34-I10)*24,IF((J10-I10)*24>=$K$5,IF(I10+($K$5/24)>$S$36,((I10+($K$5/24))-$S$36)*24,),(J10-$S$36)*24))),)))
U11,U18U11=IF(SUM(N6:N10)>=40,,IF(K11=0,,IF(OR(I11<$S$34,J11>=$S$36),IF(AND(I11<$S$34,J11>=$S$36),($S$34-I11)*24,IF(I11<$S$34,($S$34-I11)*24,IF((J11-I11)*24>=$K$5,IF(I11+($K$5/24)>$S$36,((I11+($K$5/24))-$S$36)*24,),(J11-$S$36)*24))),)))
K5:K9,K11:K16K5=(J5-I5)*24
N12,N19N12=IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),,IF(SUM(N6:N11)>=40,,IF(SUM(N6:N11)+K12<=40,IF(40-SUM(N6:N11)<$K$5,MIN($K$5,K12),K12),40-SUM(N6:N11))))
O12,O19O12=IF(K12=0,,IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),,IF(AND(K12>=$K$5,AE12=TRUE,AF12=TRUE),IF(K12<$K$5,,(K12-N12)+0.5+2),IF(AND(K12>=$K$5,AE12=TRUE,AF12=FALSE),IF(K12<$K$5,,(K12-N12)+0.5),IF(AND(K12>=$K$5,AE12=FALSE,AF12=TRUE),(K12-N12)+2,IF(AND(K12>=$K$5,AE12=FALSE,AF12=FALSE),K12-N12,IF(AND(K12<$K$5,AE12=TRUE,AF12=TRUE),(K12-N12)+2,IF(AND(K12<$K$5,AE12=TRUE,AF12=FALSE),(K12-N12),IF(AND(K12<$K$5,AE12=FALSE,AF12=TRUE),(K12-N12)+2,IF(AND(K12<$K$5,AE12=FALSE,AF12=FALSE),K12-N12))))))))))
P12,P19P12=IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),IF(AND(K12>=$K$5,AE12=TRUE,AF12=TRUE),IF(K12<$K$5,,(K12-N12)+0.5+2),IF(AND(K12>=$K$5,AE12=TRUE,AF12=FALSE),IF(K12<$K$5,,(K12-N12)+0.5),IF(AND(K12>=$K$5,AE12=FALSE,AF12=TRUE),(K12-N12)+2,IF(AND(K12>=$K$5,AE12=FALSE,AF12=FALSE),K12-N12,IF(AND(K12<$K$5,AE12=TRUE,AF12=TRUE),(K12-N12)+2,IF(AND(K12<$K$5,AE12=TRUE,AF12=FALSE),(K12-N12),IF(AND(K12<$K$5,AE12=FALSE,AF12=TRUE),(K12-N12)+2,IF(AND(K12<$K$5,AE12=FALSE,AF12=FALSE),K12-N12)))))))),)
R12,R19R12=IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),,IF(SUM(N6:N11)>=40,,IF(SUM(N6:N11)+K12<40,IF(J12<$T$34,,IF(J12<$T$35,(J12-$T$34)*24,($T$35-$T$34)*24)),IF(I12+((40-SUM(N6:N11))/24)<$T$34,,IF(I12+((40-SUM(N6:N11))/24)<$T$35,((I12+((40-SUM(N6:N11))/24))-$T$34)*24,$T$35-$T$34)))))
S12,S19S12=IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),,IF(J12>=$T$34,IF((J12-I12)*24>=$K$5,IF(I12+($K$5/24)<$T$34,IF(J12>=$T$35,($T$35-$T$34)*24,(J12-$T$34)*24),IF(J12>=$T$35,IF(I12>=$T$34,($T$35-I12)*24,($T$35-$T$34)*24),IF(I12>=$T$34,(J12-I12)*24,(J12-(I12+($K$5/24)))*24))),),))
T12,T19T12=IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),IF(J12>=$T$34,IF((J12-I12)*24>=$K$5,IF(I12+($K$5/24)<$T$34,IF(J12>=$T$35,($T$35-$T$34)*24,(J12-$T$34)*24),IF(J12>=$T$35,IF(I12>=$T$34,($T$35-I12)*24,($T$35-$T$34)*24),IF(I12>=$T$34,(J12-I12)*24,(J12-(I12+($K$5/24)))*24))),),),)
U12,U19U12=IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),,IF(SUM(N6:N11)>=40,,IF(K12=0,,IF(OR(I12<$S$34,J12>=$S$36),IF(AND(I12<$S$34,J12>=$S$36),($S$34-I12)*24,IF(I12<$S$34,($S$34-I12)*24,IF((J12-I12)*24>=$K$5,IF(I12+($K$5/24)>$S$36,((I12+($K$5/24))-$S$36)*24,),(J12-$S$36)*24))),))))
V12,V19V12=IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),,IF(K12=0,,IF(OR(I12<$S$34,J12>=$S$36),IF(AND(I12<$S$34,J12>=$S$36),(($T$36-I12)+(J12-$S$36))*24,IF(I12<$S$34,,IF((J12-I12)*24>=$K$5,IF(I12+($K$5/24)>$S$36,((I12+($K$5/24))-$S$36)*24,(J12-$S$36)*24),(J12-$S$36)*24))),)))
W12,W19W12=IF(AND(K6>=4,K7>=4,K8>=4,K9>=4,K10>=4,K11>=4),IF(K12=0,,IF(OR(I12<$S$34,J12>=$S$36),IF(AND(I12<$S$34,J12>=$S$36),(($T$36-I12)+(J12-$S$36))*24,IF(I12<$S$34,,IF((J12-I12)*24>=$K$5,IF(I12+($K$5/24)>$S$36,((I12+($K$5/24))-$S$36)*24,(J12-$S$36)*24),(J12-$S$36)*24))),)),)
R17R17=IF(SUM(N13:N16)>=40,,IF(SUM(N13:N16)+K17<40,IF(J17<$T$34,,IF(J17<#REF!,(J17-$T$34)*24,($T$35-$T$34)*24)),IF(I17+((40-SUM(N13:N16))/24)<$T$34,,IF(I17+((40-SUM(N13:N16))/24)<$T$35,((I17+((40-SUM(N13:N16))/24))-$T$34)*24,$T$35-$T$34))))
Z6Z6=Z4
Z7Z7=$Z$4+1
Z8Z8=$Z$4+2
Z9Z9=$Z$4+3
Z10Z10=$Z$4+4
Z11Z11=$Z$4+5
Z12Z12=$Z$4+6
Z13Z13=$Z$4+7
Z14Z14=$Z$4+8
Z15Z15=$Z$4+9
Z16Z16=$Z$4+10
Z17Z17=$Z$4+11
Z18Z18=$Z$4+12
Z19Z19=$Z$4+13
X6:X19X6=(N6*$N$5)+(O6*$O$5)+(P6*$P$5)+(Q6*$Q$5)+(R6*$R$5)+(S6*$S$5)+(T6*$T$5)+(U6*$U$5)+(V6*$V$5)+(W6*$W$5)
X20X20=SUM(X6:X19)
K22,N22:W22K22=SUM(K6:K19)
N24:W24N24=N22*N5
X24X24=SUM(N24:W30)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I6:X19Expression=IF(AB6=1,MATCH($Z6,HolidaysNonRotating,0),MATCH($Z6,HolidaysRotating,0))textNO
 
Upvote 0
Check this and revert - I think formula needs slight modification

Excel Formula:
=OR(And($AB$6=1,MATCH($Z6,HolidaysNonRotating,0)),And($AB$6<>1,MATCH($Z6,HolidaysRotating,0)))
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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