R
Rick Rothstein \(MVP - VB\)
example a) Site: 3480 test data migration
I think this macro function will extract the numbers you are looking for...
Function ExtractNumber(ByVal StringIn As String) As Single
Dim Extraction() As String
On Error Resume Next
StringIn = Replace(StringIn, "(", "( ")
StringIn = Replace(StringIn, "hr", Chr$(1))
StringIn = Replace(StringIn, "uur", Chr$(1))
Extraction = Split(StringIn, Chr$(1))
Extraction = Split(RTrim$(Extraction(UBound(Extraction) - 1)), " ")
ExtractNumber = CSng(Extraction(UBound(Extraction)))
End Function
Rick
1) Example a is just a number in the string, all number one numbers are
always at the end of the string, but not always between parentheses. I
also
found situation with a space between the opening parentheses and the
number.
2) Below are the formats I could expect. The abbreviations represent
worked
hours in English and Dutch.
X hr
X hrs
X uur
Xhr
Xhrs
Xuur
x.x hr
x.x hrs
x.x uur
x.xhr
x.xhrs
x.xuur
hopes this answer the question?
I think this macro function will extract the numbers you are looking for...
Function ExtractNumber(ByVal StringIn As String) As Single
Dim Extraction() As String
On Error Resume Next
StringIn = Replace(StringIn, "(", "( ")
StringIn = Replace(StringIn, "hr", Chr$(1))
StringIn = Replace(StringIn, "uur", Chr$(1))
Extraction = Split(StringIn, Chr$(1))
Extraction = Split(RTrim$(Extraction(UBound(Extraction) - 1)), " ")
ExtractNumber = CSng(Extraction(UBound(Extraction)))
End Function
Rick