Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Problem 1

Status
Not open for further replies.

Domino2

Technical User
Jun 8, 2008
475
GB
I have a string that contains possibly a forename, middle name and surname. The string is in reverse, ie

Jones Adam Gordon
or
Jones Gordon.

I need to convert tha string to make it either

Gordon Adam Jones
or Gordon Jones.

Whats the easiest way to do it, thanks
 
Check out the FAQs there are a lot of Name string manipulations. They tend to be case specific. For your case try something like:
Code:
Public Function reverseName(strName As Variant) As String
  Dim aName() As String
  If Not IsNull(strName) Then
    aName = Split(strName)
      Select Case UBound(aName)
        Case 2
          reverseName = aName(2) & " " & aName(1) & " " & aName(0)
        Case 1
          reverseName = aName(1) & " " & aName(0)
        Case Else
      End Select
  End If
End Functionn
 

What they tend to be are hairballs! Besides First and Last or First and Middle and Last, you also have two part last names (Van Zandt] each of those possibilities with Jr, Sr, III to say nothing of MD and Esq and so forth!

In the end, no matter how much you try to automate this, unless you're absolutely sure that there will be no variations on the first two possibilities, you're going to have to physically scan the results.

Good Luck!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks for replies. Majp, that works a treat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top