I am having below type of values in xls column A
Row 1 - 3min 17s 463ms
Row 2 - 19s 364ms
Row 3 - 165ms
Row 4 - 364ms
Row 5 - 4min 1s 463ms
Form my calculation I need to convert above values into ms (milli seconds), I have tried doing this (with my limited VBScripting knowledge) using split functions but I couldn't make it work :(. Can you please help.
Thank You, V2ri.
How about:
Sub millisec()
Dim A As Range, r As Range, s As String
Dim N As Long, milli As Long
N = Cells(Rows.Count, "A").End(xlUp).Row
Set A = Range("A1:A" & N)
For Each r In A
v = r.Text
ary = Split(v, " ")
milli = 0
For Each ar In ary
If Right(ar, 2) = "ms" Then
milli = milli + CLng(Replace(ar, "ms", ""))
GoTo qwerty
End If
If Right(ar, 1) = "s" Then
milli = milli + 1000& * CLng(Replace(ar, "s", ""))
GoTo qwerty
End If
milli = milli + 60& * 1000& * CLng(Replace(ar, "min", ""))
qwerty:
Next ar
r.Value = milli
Next r
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.