Isolate Numerical Data in Cell
Function School(str As String) As String
Dim re As Object
Dim mc As Object
Set re = CreateObject("vbscript.regexp")
re.Pattern = "\w[\s\S]*?(?=\s\()"
If re.test(str) = True Then
Set mc = re.Execute(str)
School = mc(0)
End If
End Function
Since we we know the school text always starts with » then....
Function School(str As String) As String
School = Trim(Mid(Split(str & "(", "(")(0), 2))
End Function
The above function assumed the school string started with the » character.
But, on the off-chance the string has the quote marks too...
Function School(str As String) As String
School = Trim(Split(Split(str, "(")(0), "»")(1))
End Function
Rick
|