Hey PGC
I was going to throw in my first Regex solution !!
Function AlphaNum(txt As String, Optional Alpha As Boolean = True) As String
'Use in cell like _
=AlphaNum(A1,True) '<- True for Alphabets, False for Numbers
With CreateObject("VBScript.RegExp")
.Pattern = IIf(Alpha, "\d+", "\D+")
.Global = True
AlphaNum = .Replace(txt, "")
End With
End Function
Function UC(s As String) As String 'Finds Name with Proper Case
'user must activate Microsoft vbscript regular expressions 5.5 in Tools / References
Application.Volatile
With CreateObject("VBScript.RegExp")
.Pattern = "(\b[A-Z]\w*\s\b[A-Z]\w*)"
If .Test(s) Then UC = .Execute(s)(0).SubMatches(0)
End With
End Function
=UC(A1)
My first crack at Regex ( with PGC's base code) was:
Code:Function UC(s As String) As String 'Finds Name with Proper Case 'user must activate Microsoft vbscript regular expressions 5.5 in Tools / References Application.Volatile With CreateObject("VBScript.RegExp") .Pattern = "(\b[A-Z]\w*\s\b[A-Z]\w*)" If .Test(s) Then UC = .Execute(s)(0).SubMatches(0) End With End Function
then use
Code:=UC(A1)