This is the data I can have:

Johnson, Tom G
Johnson Tom G
Johnson Tom

This is the function I have so far:

Function MiddleName(ByVal WholeName As String) As String
Dim arr() As String
Dim MName As String
Dim pos As Integer

WholeName = Replace(WholeName, ",", " ")
arr = Split(WholeName, " ")
pos = WholeName.IndexOf(" ")

If pos > 0 Then
MiddleName = " " + arr(2) + " "
Else
MiddleName = ""
End If
Return MiddleName

End Function

It gets the middle name, but if there is no middle name it gives me an error. How can I fix that? Please help!

Brenda