Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 32
Default Calculations on various rates

I am putting togethor a worksheet to keep track of costings through the
week. This part is for wages, and staff are paid at 2 rates. Rate 1 (R1) is
from 06:00 to 22:00, and Rate 2 (R2) is from 22:00 to 06:00. I am trying to
automate the hours worked on various shifts so that when I am building a
rosta, it automatically works out the hours worked at the different rates. I
need to keep track of R1 and R2 hours worked on each shift through out the
week (Mon - Sun). ie someone might start work at 21:30 and work through to
07:30, someone else might work 22:30 to 05:30 and someone else 09:00 to
19:00. I have got the general formula, but I cannot get it to work if
someone finishes a night shift before 06:00. C17 is the start time, E17 is
the finish time with F17 listing the total hours worked, G17 listing break to
be deducted and R1 total in H17, R2 total in I17

I would be grateful of any suggestions made. Thanks for your help
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Calculations on various rates

A formula become extreemly complicated. I would recommend a UDF like the one
below

Function Pay(StartTime, EndTime, R1, R2) As Single
DayShift = 0
NightShift = 0
'time is in days where
'1 day = 1 and 1 hour = 1/24
If EndTime < StartTime Then
EndTime = EndTime + 1 'add 1 day
End If
If StartTime < TimeValue("6:00AM") Then
If EndTime < TimeValue("6:00AM") Then
NightShift = EndTime - StartTime
Else
NightShift = TimeValue("6:00AM") - StartTime
If EndTime <= TimeValue("10:00PM") Then
DayShift = EndTime - TimeValue("6:00AM")
Else
DayShift = TimeValue("10:00PM") - TimeValue("6:00AM")
NightShift = NightShift + (EndTime - TimeValue("10:00PM"))
End If
End If
Else
If EndTime < TimeValue("10:00PM") Then
DayShift = EndTime - StartTime
Else
DayShift = TimeValue("10:00PM") - StartTime
NightShift = EndTime - TimeValue("10:00PM")
End If
End If
Pay = (24 * DayShift * R1) + (24 * NightShift * R2)
End Function


"Iain" wrote:

I am putting togethor a worksheet to keep track of costings through the
week. This part is for wages, and staff are paid at 2 rates. Rate 1 (R1) is
from 06:00 to 22:00, and Rate 2 (R2) is from 22:00 to 06:00. I am trying to
automate the hours worked on various shifts so that when I am building a
rosta, it automatically works out the hours worked at the different rates. I
need to keep track of R1 and R2 hours worked on each shift through out the
week (Mon - Sun). ie someone might start work at 21:30 and work through to
07:30, someone else might work 22:30 to 05:30 and someone else 09:00 to
19:00. I have got the general formula, but I cannot get it to work if
someone finishes a night shift before 06:00. C17 is the start time, E17 is
the finish time with F17 listing the total hours worked, G17 listing break to
be deducted and R1 total in H17, R2 total in I17

I would be grateful of any suggestions made. Thanks for your help

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Calculations on various rates

I found some cases that were wrong. Here are the corrections

Function Pay(StartTime, EndTime, R1, R2) As Single
Dim DayShift As Single
Dim NightShift As Single

DayShift = 0#
NightShift = 0#

'time is in days where
'1 day = 1 and 1 hour = 1/24
If EndTime < StartTime Then
EndTime = EndTime + 1 'add 1 day
End If
If StartTime < TimeValue("6:00AM") Then
If EndTime < TimeValue("6:00AM") Then
NightShift = EndTime - StartTime
Else
NightShift = TimeValue("6:00AM") - StartTime
If EndTime <= TimeValue("10:00PM") Then
DayShift = EndTime - TimeValue("6:00AM")
Else
DayShift = TimeValue("10:00PM") - TimeValue("6:00AM")
NightShift = NightShift + (EndTime - TimeValue("10:00PM"))
End If
End If
Else
If StartTime < TimeValue("10:00PM") Then
If EndTime < TimeValue("10:00PM") Then
DayShift = EndTime - StartTime
Else
DayShift = TimeValue("10:00PM") - StartTime
If EndTime < (1 + TimeValue("6:00AM")) Then
NightShift = EndTime - TimeValue("10:00PM")
Else
DayShift = DayShift + (EndTime - (1 + TimeValue("6:00AM")))
NightShift = (1 + TimeValue("6:00AM")) - TimeValue("10:00PM")
End If
End If
Else
If EndTime < (1 + TimeValue("6:00AM")) Then
NightShift = EndTime - StartTime
Else
DayShift = (EndTime - (1 + TimeValue("6:00AM")))
NightShift = (1 + TimeValue("6:00AM")) - TimeValue("10:00PM")
End If
End If
End If
Pay = (24 * DayShift * R1) + (24 * NightShift * R2)
End Function


"Joel" wrote:

A formula become extreemly complicated. I would recommend a UDF like the one
below

Function Pay(StartTime, EndTime, R1, R2) As Single
DayShift = 0
NightShift = 0
'time is in days where
'1 day = 1 and 1 hour = 1/24
If EndTime < StartTime Then
EndTime = EndTime + 1 'add 1 day
End If
If StartTime < TimeValue("6:00AM") Then
If EndTime < TimeValue("6:00AM") Then
NightShift = EndTime - StartTime
Else
NightShift = TimeValue("6:00AM") - StartTime
If EndTime <= TimeValue("10:00PM") Then
DayShift = EndTime - TimeValue("6:00AM")
Else
DayShift = TimeValue("10:00PM") - TimeValue("6:00AM")
NightShift = NightShift + (EndTime - TimeValue("10:00PM"))
End If
End If
Else
If EndTime < TimeValue("10:00PM") Then
DayShift = EndTime - StartTime
Else
DayShift = TimeValue("10:00PM") - StartTime
NightShift = EndTime - TimeValue("10:00PM")
End If
End If
Pay = (24 * DayShift * R1) + (24 * NightShift * R2)
End Function


"Iain" wrote:

I am putting togethor a worksheet to keep track of costings through the
week. This part is for wages, and staff are paid at 2 rates. Rate 1 (R1) is
from 06:00 to 22:00, and Rate 2 (R2) is from 22:00 to 06:00. I am trying to
automate the hours worked on various shifts so that when I am building a
rosta, it automatically works out the hours worked at the different rates. I
need to keep track of R1 and R2 hours worked on each shift through out the
week (Mon - Sun). ie someone might start work at 21:30 and work through to
07:30, someone else might work 22:30 to 05:30 and someone else 09:00 to
19:00. I have got the general formula, but I cannot get it to work if
someone finishes a night shift before 06:00. C17 is the start time, E17 is
the finish time with F17 listing the total hours worked, G17 listing break to
be deducted and R1 total in H17, R2 total in I17

I would be grateful of any suggestions made. Thanks for your help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tax Rates Greyson Excel Discussion (Misc queries) 2 November 8th 06 11:15 PM
Tax rates PJOS11 Excel Discussion (Misc queries) 13 January 9th 06 04:20 PM
Can't add new rates II Blissfully Ignorant Excel Discussion (Misc queries) 6 December 22nd 05 07:50 PM
Can't add pay rates Blissfully Ignorant Excel Worksheet Functions 2 December 22nd 05 07:34 PM
Can't add new rates Blissfully Ignorant Excel Discussion (Misc queries) 1 December 21st 05 09:56 PM


All times are GMT +1. The time now is 11:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"