Parse Names

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all...I need help. I need to parse data which is formatted as follows:
First Name Middle Name Last Name - Example:
John M Doe
I can parse data by using the mid/left functions but I am at lost with this
example above.
Any help is greatly appreciated....
 
Parsing names is almost impossible to get 100% accuracy. However, if it is
always first middle last separated by spaces, you could use the Split
function to put the parts in an array, then more the array elements to
separate varialbes.

Dim varAllParts As Variant
Dim strFirst As String
Dim strMid As String
Dim strLast As String

varAllParts = Split(TheWholeName, " ")

strFirst = varAllParts(0)
If UBound(varAllParts) = 2 Then
strMid = varAllParts(1)
strLast = varAllParts(2)
Else
strLast = varAllParts(1)
End If

This will also account for those poor unfortunates who can't afford a middle
name.
 
Back
Top