Parse Names

F

FJinSA

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....
 
K

Klatuu

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top