LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default Sum work hours to hours & nearest 10th of an hour

On the active sheet that represents a given month of the year:

Column D = employee who has signed in
Column E = Date in
Column F = sign in time
Column G = Date out
Column H = sign out time

Sarah 7/16/2014 9:44 PM 7/16/2014 10:22 PM
Jaydee 7/16/2014 9:44 PM 7/16/2014 10:48 PM
Frank 7/16/2014 10:51 PM

Column M = A unique list of all employees.

Employees will be signed in and out several times.
Not every employee in column M will be signed in (some may not work that month)
Some will be signed in but not signed out when the code is run during the course of the month.

Trying to get this line to return all hours worked and minutes to the nearest 10th to column N next to employee name.

ie. every 6 minutes = .1 of an hour.


cM.Offset(, 1) = (cD.Offset(, 4) - cD.Offset(, 2)) + (cM.Offset(, 1))


So each time code is run, column N is cleared and all hours are updated.

What I have right now is values that pretty much don't mean anything to me, and some are negative.

Column N formatted as General until I know what it should be.

I would expect the code to be run on the active sheet so it could used for all months, with each month on a sheet.

Thanks,
Howard


Sub NameAndHours()

Dim Mname As Range, Dname As Range
Dim cM As Range, cD As Range
Dim i As Long

Set Mname = Range("M2:M" & Cells(Rows.Count, "M").End(xlUp).Row)
Set Dname = Range("D2:D" & Cells(Rows.Count, "D").End(xlUp).Row)

For Each cM In Mname

For Each cD In Dname

If cM = cD Then

cM.Offset(, 1) = (cD.Offset(, 4) - cD.Offset(, 2)) + (cM.Offset(, 1))

End If

Next

Next

End Sub
 
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
work hours with different hour prices [email protected] Excel Worksheet Functions 12 January 29th 14 11:03 PM
Converting work hours to day/hours/minutes WxmanPrice Excel Discussion (Misc queries) 3 October 20th 09 03:08 PM
Determining work hours between dates / hours Andrew Excel Worksheet Functions 3 July 30th 08 06:38 PM
total work hours for 24 hour on-call schedules Kate Excel Discussion (Misc queries) 1 February 7th 06 03:01 AM
Apply a macro to all sheets - save me from hours and hours of work Excel'ed Failures Excel Programming 3 January 30th 06 05:48 PM


All times are GMT +1. The time now is 04:32 AM.

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

About Us

"It's about Microsoft Excel"