Formula to show a zero when options is not there.

Robert Wyatt

Board Regular
Joined
Jul 15, 2012
Messages
108
Office Version
  1. 2019
Platform
  1. Windows
I'm trying to fix up a time sheet to show hours worked in corresponding cells I have included a XL2BB copy of what I'm working on and how I would like for it to work. can you tell me how to make it show zero when options show Off. once you look at the sample, I'm sure yo
Book3.xlsm
ABCDEFGHIJKL
1Overtime Options
2FALSE
3After:8Hrs
4
5TRUETRUE
6After:40Hrs
7
8
9
10
11
12
13
14
15
16
17WeekdayOptionsShift StartsLunch StartsLunch endsShift EndsTotal HrsRegular HrsOvertime HrsSick Holidayvacation
18
19Mon 12/30Regular8:00 AM11:30 AM12:00 PM4:30 PM8.008.00-FALSEFALSEFALSE
20Tue 12/31Regular8:00 AM11:30 AM12:00 PM4:30 PM8.008.00-FALSEFALSEFALSE
21Wed 01/01Holiday8:00 AM11:30 AM12:00 PM4:30 PMFALSE--FALSE8.00FALSE
22Thu 01/02Regular8:00 AM11:30 AM12:00 PM4:30 PM8.008.00-FALSEFALSEFALSE
23Fri 01/03Regular8:00 AM11:30 AM12:00 PM4:30 PM8.008.00-FALSEFALSEFALSE
24Sat 01/04OffFALSE--FALSEFALSEFALSE
25Sun 01/05OffFALSE--FALSEFALSEFALSE
26Total Hrs:32.00--8.00-
Sheet1
Cell Formulas
RangeFormula
H19:H25H19=G19-I19
I19:I25I19=ROUND(MAX(IF($K$5,MAX(0,SUM(H$18:H18)+G19-$K$6),0),IF($K$2,IF(G19>$K$3,G19-$K$3,0),0)),2)
J19:J25J19=IF(B19="Sick",MROUND((MOD(F19-C19,1)-MOD(E19-D19,1))*24,1/4))
K19:K25K19=IF(B19="Holiday",MROUND((MOD(F20-C20,1)-MOD(E20-D20,1))*24,1/4))
L19:L25L19=IF(B20="Vacation",MROUND((MOD(F20-C20,1)-MOD(E20-D20,1))*24,1/4))
H26:L26H26=SUM(H19:H25)
G19:G25G19=IF(B19="REGULAR",MROUND((MOD(F19-C19,1)-MOD(E19-D19,1))*24,1/4))
u'll see what I'm doing.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi Robert,

Just add another IF statement where required so the formula in G19 would become this:

Excel Formula:
=IF(B19="Off",0,IF(B19="REGULAR",MROUND((MOD(F19-C19,1)-MOD(E19-D19,1))*24,1/4)))

I'd also check the formulas for Holidays and Vacation (columns K and L respectively) as I think they are out by one row.

Regards,

Robert
 
Upvote 0
I tried it with the formula showed above, but it still adds the hours to both regular and sick. What is it I'm doing wrong? If I have regular showing in options, I need it to add the hours to regular, If I have sick in options, I need it to add or hour to regular and 8 hours to Sick. Same for Holiday and Vacation if options show it to be Vacation or Holiday. I use to have a time sheet made up like that before, but the life of me I can't find it anywhere.
 
Upvote 0
What is it I'm doing wrong?

Not sure 🤔 Besides Col. G you need to add the extra IF statement to the formulas in columns J, K and L. Did you do that? If so, if you change B19 to "Off" you should only see zeros. Also make sure the formulas in columns K and L are referenced correctly (as I mention above) and that the calculation method for the sheet is set to automatic.

Beyond that I'm not sure I'm afraid.
 
Upvote 0
Though it didn't help I do thank you for trying. I will just give up and move on to something else. Sense it didn't work don't know if I should click the check mark or not if so let me know and I'll come back to take care of it. Thanks again for trying to help.
 
Upvote 0
Can you please update all the formulas and re-post sheet?
 
Upvote 0
As you can see it is placing time in both sick and regular hours place when it is marked regular hours and show false when marked off


Book3.xlsm
ABCDEFGHIJKL
17WeekdayOptionsShift StartsLunch StartsLunch EndsShift EndsTotal HrsRegular HrsOvertime HrsSick Holidayvacation
18
19 Sick8:00 AM4:00 PMFALSE--8.00FALSEFALSE
20 Holiday8:00 AM4:00 PMFALSE--FALSE8.00FALSE
21 Vacation8:00 AM4:00 PMFALSE--FALSEFALSE8.00
22 Regular8:00 AM4:00 PM8.008.00-8.00FALSEFALSE
23 OFF---FALSE--
24 OFF---FALSE--
25 OFF---FALSE--
26Total Hrs:8.00-16.008.008.00
27Pay Rate / Hourly:$14.99$22.49$14.99$14.99$14.99
28Pay:$119.92$0.00$239.84$119.92$119.92
29
30Grand Total Gross:$599.60
Time Sheet
Cell Formulas
RangeFormula
I19:I25I19=ROUND(MAX(IF('Data Sheet'!$B$5,MAX(0,SUM(H$18:H18)+G19-'Data Sheet'!$B$6),0),IF('Data Sheet'!$B$2,IF(G19>'Data Sheet'!$B$3,G19-'Data Sheet'!$B$3,0),0)),2)
J19J19=IF(B19="Off",0,IF(B19="Sick",MROUND((MOD(F19-C19,1)-MOD(E19-D19,1))*24,1/4)))
K19:K25K19=IF(B19="Off",0,IF(B19="Holiday",MROUND((MOD(F19-C19,1)-MOD(E19-D19,1))*24,1/4)))
L19:L25L19=IF(B19="Off",0,IF(B19="Vacation",MROUND((MOD(F19-C19,1)-MOD(E19-D19,1))*24,1/4)))
J20:J25J20=IF(B20="Sick",0,IF(B20="REGULAR",MROUND((MOD(F20-C20,1)-MOD(E20-D20,1))*24,1/4)))
H26:L26I26=SUM(I19:I25)
I27I27=ROUND(1.5*H27,2)
J27J27=H27
K27K27=H27
L27L27=H27
A19A19=IF($D$12="","",$D$12)
A20A20=IF($D$12="","",$D$12+1)
A21A21=IF($D$12="","",$D$12+2)
A22A22=IF($D$12="","",$D$12+3)
A23A23=IF($D$12="","",$D$12+4)
A24A24=IF($D$12="","",$D$12+5)
A25A25=IF($D$12="","",$D$12+6)
G19:G25G19=IF(B19="Off",0,IF(B19="REGULAR",MROUND((MOD(F19-C19,1)-MOD(E19-D19,1))*24,1/4)))
H19:H25H19=G19-I19
H28:L28H28=ROUND(H27*H26,2)
K30K30=SUM(H28:L28)
Cells with Data Validation
CellAllowCriteria
B19:B25List='Data Sheet'!$I$2:$I$13
 
Upvote 0
Does the attached screen shot reconcile to your expectations?
 

Attachments

  • RWhatt.jpg
    RWhatt.jpg
    41.6 KB · Views: 6
Upvote 0
Try these formulas with the given range (I've left the overtime hours in Col. I as they reference another sheet)

G19:G25
Excel Formula:
=IF(B19="Off",0,MROUND((MOD(F19-C19,1)-MOD(E19-D19,1))*24,1/4))
H19:H25
Excel Formula:
=IF(B19="Regular",G19-I19,0)
J19:J25
Excel Formula:
=IF(B19="Off",0,IF(B19="Sick",G19,0))
K19:K25
Excel Formula:
=IF(B19="Off",0,IF(B19="Holiday",G19,0))
L19:L25
Excel Formula:
=IF(B19="Off",0,IF(B19="Vacation",G19,0))
 
Upvote 0
Solution

Forum statistics

Threads
1,225,371
Messages
6,184,581
Members
453,244
Latest member
Todd Luet

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