N
nrage21
Could you please help me with this function again?
It seems that I didnt test it enough and it's returning some inaccurat
results.
Function sum_pseudo_time(rng As Range) As String
Dim cell As Range
Dim ret_str As String
Dim ret_value
Dim time_str As String
ret_value = 0
For Each cell In rng
If cell.Value <> "" Then
time_str = Replace(Replace(Replace(cell.Value, "H", ""), _
"M", ""), _
"D", "")
ret_value = ret_value + CDate(time_str)
End If
Next
With Application.WorksheetFunction
ret_str = .RoundDown(ret_value, 0) & "D:" & _
.RoundDown((ret_value - .RoundDown(ret_value, 0)) * 24, 0) & _
"H:" & CInt((ret_value * 24 - .RoundDown(ret_value * 24, 0)) * 60) & _
"M"
End With
sum_pseudo_time = ret_str
End Function
I'm trying to add:
12D:20H:36M
12D:17H:20M
12D:1H:32M
and it's giving me: 1D:12H:39M
this of course should be: 37D:15H:28M
TIA Frank!
- Larry -
VBA Amateu
It seems that I didnt test it enough and it's returning some inaccurat
results.
Function sum_pseudo_time(rng As Range) As String
Dim cell As Range
Dim ret_str As String
Dim ret_value
Dim time_str As String
ret_value = 0
For Each cell In rng
If cell.Value <> "" Then
time_str = Replace(Replace(Replace(cell.Value, "H", ""), _
"M", ""), _
"D", "")
ret_value = ret_value + CDate(time_str)
End If
Next
With Application.WorksheetFunction
ret_str = .RoundDown(ret_value, 0) & "D:" & _
.RoundDown((ret_value - .RoundDown(ret_value, 0)) * 24, 0) & _
"H:" & CInt((ret_value * 24 - .RoundDown(ret_value * 24, 0)) * 60) & _
"M"
End With
sum_pseudo_time = ret_str
End Function
I'm trying to add:
12D:20H:36M
12D:17H:20M
12D:1H:32M
and it's giving me: 1D:12H:39M
this of course should be: 37D:15H:28M
TIA Frank!
- Larry -
VBA Amateu