G
Graysailor
Interesting one. I have a calculation subroutine that goes row by row to see
if there are any matching records that have three same fields of information
in them. If they do then it tries to replace the value of the last record
with a formula that will calcuate a difference between two times.
Unfortunately I don't know how to pass the " marks in the
TEXT(CELL1-CELL2,"h:mm") formula. Or I could try calculating the time
difference in the routine and just passing the value, but I don't know how to
use an excel function in a VB subroutine (the problem is that the values are
TIMES in the cells to be calculated). It's Friday, I'm toast.
Sub CalculateTurnover()
For n = 2 To 5392 (my row range)
Rem - see if date, employee and room match (columns 3,4,10) with the
following row
If (Cells(n, 3) = Cells(n + 1, 3)) And (Cells(n, 4) = Cells(n + 1, 4)) And
(Cells(n, 10) = Cells(n + 1, 10)) Then
Rem - if so put formula to calculate time difference and store it into
column 12
Cells(n + 1, 12).Formula = "=TEXT(" & Cells(n, 9).Value & "-" &
Cells(n + 1, 5).Value & ',"h:mm")'
End If
Next n
End Sub
if there are any matching records that have three same fields of information
in them. If they do then it tries to replace the value of the last record
with a formula that will calcuate a difference between two times.
Unfortunately I don't know how to pass the " marks in the
TEXT(CELL1-CELL2,"h:mm") formula. Or I could try calculating the time
difference in the routine and just passing the value, but I don't know how to
use an excel function in a VB subroutine (the problem is that the values are
TIMES in the cells to be calculated). It's Friday, I'm toast.
Sub CalculateTurnover()
For n = 2 To 5392 (my row range)
Rem - see if date, employee and room match (columns 3,4,10) with the
following row
If (Cells(n, 3) = Cells(n + 1, 3)) And (Cells(n, 4) = Cells(n + 1, 4)) And
(Cells(n, 10) = Cells(n + 1, 10)) Then
Rem - if so put formula to calculate time difference and store it into
column 12
Cells(n + 1, 12).Formula = "=TEXT(" & Cells(n, 9).Value & "-" &
Cells(n + 1, 5).Value & ',"h:mm")'
End If
Next n
End Sub