VBA or Excel – Time sheet with RT / OT based on the day of the week.

JDSOuth49

New Member
Joined
Feb 16, 2024
Messages
46
Office Version
  1. 365
Platform
  1. Windows
I need help with VBA Code or an Excel formula.

PURPOSE: I need to auto calculate OT based on the days of the week (Saturday & Sunday).

For Monday – Friday any hours as follows: [**This part of the sheet works fine]

Cell Range = F15,P15:F50,P50

In Cell Q15 formula: =IF(S15<8,S15,8)

In Cell R15 formula: =IF(S15-8>0,(S15-8),0)

In Cell S15 formula: =SUM(F15:P15)

For Saturday and Sunday Only: [This is where I am having my Issue]

I am wanting to have ANY time on Saturday or Sunday Counted as “Overtime Only” {Column R, Rows 15 to 50}

Cell “C5” is set to return the Day of the weeks using the following formula: =IF(C6="","",TEXT(C6,"dddd"))


Any help would be greatly appreciated
 

Attachments

  • Time Sheet.png
    Time Sheet.png
    29.9 KB · Views: 12

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Thank you for the suggestion, but it interferes with the following formulas:

In Cell Q15 formula: =IF(S15<8,S15,8)
In Cell R15 formula: =IF(S15-8>0,(S15-8),0)
In Cell S15 formula: =SUM(F15:P15)

and I do not know how to get around that.
 
Upvote 0
I was not telling you to replace entiredly, but to use it in your formulas.
Look at this:
NOTE: This is using Date values in Column C, not a text version of a date (the cells are formatted dates, formats of dddd or dddd yyyy-mm-dd).
(Edited at 11:29, I did not put the 2nd argument in the Weekday Function in the original).

Book1
CFGHIJKLMNOPQRS
1
2
3
4
5Saturday
6Saturday 2024-01-20
7
8
9
10
11
12
13
14HRSHRSHRSHRSHRSHRSHRSHRSHRSHRSHRSRegO/TTotal
15111111111099
16Testing Random Days
17Saturday 2024-01-20111111066
18Sunday 2024-01-21111111111099
19Monday 2024-01-22111111606
20Tuesday 2024-01-2311111111118210
21Wednesday 2024-01-241111404
22Thursday 2024-01-251111404
23Friday 2024-01-2611111111808
24Saturday 2024-01-27111111111099
25Sunday 2024-01-281111044
26Monday 2024-01-291111404
27Tuesday 2024-01-301111404
28Wednesday 2024-01-3111111111118210
29Thursday 2024-02-01000
Sheet1
Cell Formulas
RangeFormula
C5C5=C6
Q15Q15=IF(WEEKDAY(C5,2)<=5,IF(S15>8,8,S15),0)
R15R15=IF(WEEKDAY(C5,2)>5,S15,IF(S15>8,S15-8,0))
S15S15=SUM($F$15:$P$15)
Q17:Q29Q17=IF(WEEKDAY(C17,2)<=5,IF(S17>8,8,S17),0)
R17:R29R17=IF(WEEKDAY(C17,2)>5,S17,IF(S17>8,S17-8,0))
S17:S29S17=SUM($F17:$P17)
C18:C29C18=C17+1
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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