I have a worksheet that contains three columns
Columns A and B contain identifier strings, and column C contains a time value in the format hh:mm
I am trying to write a function that stores, on a separate summary sheet, the total time where columns A and B contain specific data (e.g. if there are 2 entries where A = "xxx" and B = "yyy" and the time entries are "11:55" and "13:15" the result should be "25:10", so I have used the numberformat as below)
I have this in my main function:
and this is the function:
I have tried several variations of this but it always returns 0:00.
Can anyone kindly point out my errors?
Many thanks
Columns A and B contain identifier strings, and column C contains a time value in the format hh:mm
I am trying to write a function that stores, on a separate summary sheet, the total time where columns A and B contain specific data (e.g. if there are 2 entries where A = "xxx" and B = "yyy" and the time entries are "11:55" and "13:15" the result should be "25:10", so I have used the numberformat as below)
I have this in my main function:
Code:
Worksheets("Summary").Range("C" & j).Value = addtime(sF, sS)
Worksheets("Summary").Range("C" & j).NumberFormat = "[h]:mm"
and this is the function:
Code:
Function calctime(sF, sS) As Double
Dim i As Integer, l As Integer
Dim tot As Double
tot = 0
l = FindLastRow("Sheet1")
For i = 2 To l
If (Worksheets("Sheet1").Range("A" & i).Value = sF) And (Worksheets("Sheet1").Range("B" & i).Value = sS) Then
tot = tot + Worksheets("Sheet1").Range("C" & i).Value
End If
Next
addtime = tot
End Function
I have tried several variations of this but it always returns 0:00.
Can anyone kindly point out my errors?
Many thanks