Hi
In several lists, data is reflected as Initials Surname. How can I change
it to Surname Initials, by using a macro?
In this UDF, "Initials" is defined as on or more sequences of one or two
capital letters (followed by a <space>). The Initials are placed at the end of
the string.
The following is the result:
Powers Powers
J Powers Powers J
J D Powers Powers J D
Cher Cher
Sonny & Cher Sonny & Cher
1 2 3 4 9999 1 2 3 4 9999
De La Smith De La Smith
JJ De La Smith De La Smith JJ
====================================
Function SurnameFirst(str As String) As String
Dim oRegex As Object
Const sPattern As String = "(([A-Z]{1,2}\s)*)(.*)"
Set oRegex = CreateObject("VBScript.RegExp")
With oRegex
.Global = True
.IgnoreCase = False
.Pattern = sPattern
End With
SurnameFirst = oRegex.Replace(str, "$3 $1")
End Function
===========================
--ron