Function TimespanToTotalSeconds(timespan As Range) As Long
Dim nv As Long
s = Split(timespan.Value) ' 0 0:36:15.0
nv = 24# * 60# * 60# * s(0)
nv = nv + 60# * 60# * s(1)
nv = nv + 60# * s(2)
nv = nv + s(3)
TimespanToTotalSeconds = nv
End Function
Function TimespanToTotalMilliseconds(timespan As Range) As Long
Dim nv As Long
s = Split(timespan.Value) ' 0 0:36:15.0
nv = 24# * 60# * 60# * s(0)
nv = nv + 60# * 60# * s(1)
nv = nv + 60# * s(2)
nv = nv + s(3)
nv = nv * 1000 + s(4)
TimespanToTotalMilliseconds = nv
End Function
' Timespan format ' 0 0:36:15.0 Public Function Split(ByVal InputText As String, _ Optional ByVal Delimiter As String) As Variant
' This function splits the sentence in InputText into
' words and returns a string array of the words. Each
' element of the array contains one word.
' This constant contains punctuation and characters
' that should be filtered from the input string.
Const CHARS = ".!?,;:""'()[]{} "
Dim strReplacedText As String
Dim intIndex As Integer
' Replace tab characters with space characters.
strReplacedText = Trim(Replace(InputText, _
vbTab, " "))
' Filter all specified characters from the string.
For intIndex = 1 To Len(CHARS)
strReplacedText = Trim(Replace(strReplacedText, _
Mid(CHARS, intIndex, 1), " "))
Next intIndex
' Loop until all consecutive space characters are
' replaced by a single space character.
Do While InStr(strReplacedText, " ")
strReplacedText = Replace(strReplacedText, _
" ", " ")
Loop
' Split the sentence into an array of words and return
' the array. If a delimiter is specified, use it.
'MsgBox "String:" & strReplacedText
If Len(Delimiter) = 0 Then
Split = VBA.Split(strReplacedText)
Else
Split = VBA.Split(strReplacedText, Delimiter)
End If
End Function
Dim nv As Long
s = Split(timespan.Value) ' 0 0:36:15.0
nv = 24# * 60# * 60# * s(0)
nv = nv + 60# * 60# * s(1)
nv = nv + 60# * s(2)
nv = nv + s(3)
TimespanToTotalSeconds = nv
End Function
Function TimespanToTotalMilliseconds(timespan As Range) As Long
Dim nv As Long
s = Split(timespan.Value) ' 0 0:36:15.0
nv = 24# * 60# * 60# * s(0)
nv = nv + 60# * 60# * s(1)
nv = nv + 60# * s(2)
nv = nv + s(3)
nv = nv * 1000 + s(4)
TimespanToTotalMilliseconds = nv
End Function
' Timespan format ' 0 0:36:15.0 Public Function Split(ByVal InputText As String, _ Optional ByVal Delimiter As String) As Variant
' This function splits the sentence in InputText into
' words and returns a string array of the words. Each
' element of the array contains one word.
' This constant contains punctuation and characters
' that should be filtered from the input string.
Const CHARS = ".!?,;:""'()[]{} "
Dim strReplacedText As String
Dim intIndex As Integer
' Replace tab characters with space characters.
strReplacedText = Trim(Replace(InputText, _
vbTab, " "))
' Filter all specified characters from the string.
For intIndex = 1 To Len(CHARS)
strReplacedText = Trim(Replace(strReplacedText, _
Mid(CHARS, intIndex, 1), " "))
Next intIndex
' Loop until all consecutive space characters are
' replaced by a single space character.
Do While InStr(strReplacedText, " ")
strReplacedText = Replace(strReplacedText, _
" ", " ")
Loop
' Split the sentence into an array of words and return
' the array. If a delimiter is specified, use it.
'MsgBox "String:" & strReplacedText
If Len(Delimiter) = 0 Then
Split = VBA.Split(strReplacedText)
Else
Split = VBA.Split(strReplacedText, Delimiter)
End If
End Function