Isolate Numerical Data in Cell
Function SchoolNums(str As String, Index As Long)
Dim re As Object
Dim mc As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\((\d+)-(\d+)-(\d+)"
If re.test(str) = True Then
Set mc = re.Execute(str)
SchoolNums = mc(0).submatches(Index - 1)
End If
End Function
And the final one-liner....
Function SchoolNums(str As String, Index As Long)
SchoolNums = Split(Mid(Replace(str, ")", "-"), _
InStr(str, "(") + 1), "-")(Index - 1)
End Function
Rick
|