need formula for counting employees by hour

D

David

have data in one cell that shows workers hours by day 04:00-12:30 based on a
7 day work week with days off which would show as "off" or "/"
have several employees that work different hours but require so many works
on the job through out the day to complete a task which in turn need to make
sure I have sufficient workers on duty

looking for a formula on how many employees working on half hour
 
R

Rick Rothstein

Can we have a little more information please? Where are you workers names...
in a row or column (which row or column would be helpful too)? Which row or
column is the worker's hours in? When does your work day start and end? For
days off... when you use a "/"... is that all that is in the cell or is
there other text combined with it? Anything else about your layout that
would affect the calculation (lunch or break times for example)? You have to
remember that when you ask a question on a newsgroup, no one here know
anything about the layout you are using, so you have to tell us, in enough
detail, so we can visualize what your set up is.
 
D

David

Workers Name are in column "a" then Sunday thru Saturday

columns b thru h the cells below the day of the week would show the shift
for each
employee such as 04:00-12:30 I wanted to populate the hours of the day below
each day of the week at 30 min time frame hope this helps
 
R

Rick Rothstein

You didn't answer all the questions I asked...

1) What time does the day's work start at and what time does the days work
end at (or do you want a 24-hour report by half-hours per day)?

2) When you use a "/" for days off, is that all that is in the cell or is
there other text coupled with it?

3) Are there any breaks in the schedule when no work is performed, such as
for lunch?
 
D

David

Sorry Rick

24 hour report Half hours

/ equals to a day the employee is not at work such as leave or training day,
Off equals employees regular day off.

Am not concerned with breaks or lunchs that is left to supervison based on
current work loads.

David
 
R

Rick Rothstein

Give this macro a try...

Sub Create15MinuteIntervals()
Dim X As Long
Dim Y As Long
Dim Z As Long
Dim LastRow As Long
Dim QuarterHours(0 To 95, 2 To 8) As Long
Dim Parts() As String
With Worksheets("Sheet1")
LastRow = .Cells(2, "A").End(xlDown).Row
For X = 2 To 8
For Y = 2 To LastRow
Parts = Split(.Cells(Y, X).Value, "-")
If UBound(Parts) = 1 Then
For Z = DateDiff("n", 0, CDate(Parts(0))) \ 15 To _
DateDiff("n", 0, CDate(Parts(1))) \ 15
QuarterHours(Z, X) = QuarterHours(Z, X) + 1
Next
End If
Next
Next
LastRow = LastRow + 2
.Rows((LastRow) & ":" & (LastRow + 96)).Clear
For X = 1 To 8
For Y = 0 To 95
If X = 1 Then
.Cells(LastRow + Y, 1).Value = Format(TimeSerial(0, 15 * Y, 0), _
"hh:mm") & " - " & Format(TimeSerial(0, 15 * Y + 14, 0), "hh:mm")
ElseIf QuarterHours(Y, X) <> 0 Then
.Cells(LastRow + Y, X).Value = QuarterHours(Y, X)
End If
Next
Next
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top