Another name function...help!
This is the data I can have:
Gomez Maria F
Gomez Maria
Gomez
When I just have the last name and nothing else, it gives me an error. How can I fix this?
Here is the function:
Function FirstName(ByVal WholeName As String) As String
Dim arr() As String
Dim FName As String
WholeName = Replace(WholeName, ",", " ")
arr = Split(WholeName, " ")
If arr(1) = "III" Or arr(1) = "JR" Or arr(1) = "SR" Or arr(1) = "II" Then
Try
FName = arr(2)
Catch ex As Exception
FName = ""
End Try
Else
Try
FName = arr(1)
Catch ex As Exception
FName = ""
End Try
End If
Return FName
End Function