LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Calculate Time

On Jan 9, 9:52*am, WLMPilot
wrote:
Sorry, forgot you were working with a macro. *I am not sure I am answering
your question, but the formula below will convert the to hours vs. hrs:mins
worked.
I also am currently working with a macro and the following was suggested to
me in order to get the time worked converted to hours, instead of
hours/minutes. I use a userform to input the time in/out, but I believe *you
are pulling in that data from a spreadsheet.

ttltime2 = 24 * (CDate(TextBox3.Value) - CDate(TextBox2.Value))

Textbox3 = time clocked out
Textbox2 = Time clocked in.
DIM ttltime2 As Double

Les



" wrote:
Is there away to go through excel and sum the only the total hours
that someone has worked for each day


The format that my excel worksheet is:


Name1
* 12/15/2007 0:41 | Out
* 12/15/2007 0:44 | Out
* 12/15/2007 0:44 | IN
* 12/15/2007 0:44 | IN
* 12/15/2007 16:11 | IN
* 12/15/2007 16:18| Out
* 12/17/2007 *9:03 | IN
* 12/17/2007 *12:27 | OUT
* 12/17/2007 *12:51 | IN
* 12/17/2007 *17:08| Out


Etc for all users the "|" represents the next column


In the last column I have calculated all *if the times by using the
following formula in a Macro


=A4-A3+IF(A3A4,1)


But this gives me everything. *Now I need to calculate just the times
that the person has worked throughout one day (it does not matter if
it is during a weekend; I just need the total hours)- Hide quoted text -


- Show quoted text -


Thank you for your help. What I decided to to do is create the
formula in the Macro. By doing this I do not have to worry about
calculating all of the IN times; excel will do this for me through the
formula once I find the range

Below is my code

Dim sFormula1 As String
Dim i As String
Dim j As String
Dim k As String
Dim Date1 As Date
Dim Date2 As Date
Range("C1").Select
Date1 = ActiveCell.Offset(0, -2)
Do While ActiveCell.Value < ""
Date1 = ActiveCell.Offset(0, -2)
If ActiveCell.Offset(0, -2) = Date1 Then
Do While ActiveCell.Offset(0, -2).Value = Date1
If ActiveCell.Offset(0, -1).Value = "IN" Then
i = ActiveCell.Row

End If
j = i
If j < "" Then
k = k & "," & "C" & j
If k = "," & "C" & j Then
k = "C" & j
End If
End If
j = ""
i = ""

ActiveCell.Offset(1, 0).Select
Loop
sFormula1 = "=SUM(" & k & ")"
ActiveCell.Offset(-1, 1).Value = sFormula1

End If
k = ""
ActiveCell.Offset(1, 0).Select
Loop

This is not probably the most perficient way but it seems to work.
The reason why I do have all of the time s seperated by IN and OUT is
because this report is recorded by our dorr badges ans we enter the
building. The excel file is just a data dump into a CSV file

If you do know an easier way to code this it would be greatly
appreciated

Once again I thank you for your help
 
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
Excel 2007 calculate time between 2 date/time columns Kevo Excel Discussion (Misc queries) 8 April 25th 09 12:02 AM
Calculate Ending time using Start Time and Elapsed Time Chief 711 Excel Worksheet Functions 5 May 13th 08 04:34 PM
calculate hours using start time & end time, excluding weekends noname Excel Programming 6 April 10th 07 03:30 PM
IF statement to calculate time usage in specific time bands Daren Excel Worksheet Functions 6 January 31st 07 01:34 PM
how to calculate time start & time finish in quarter hour Peter Wu Excel Discussion (Misc queries) 3 June 7th 06 12:58 AM


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

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"