Extract last names with variable formats?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JP Romano
    New Member
    • Oct 2008
    • 11

    Extract last names with variable formats?

    Hi... I need some help with either a formula or vba routine that will extract last names for a comparison. The names can come into my spreadsheet as any of the following
    John Doe
    John J Doe
    Jonh Jason Doe
    John Jason Lee Doe
    I've already stripped out all of the suffixes (Jr., Sr, CFA, MD, etc) and am using the following formula. The problem is, for some reason some of the results are blank. I copied this formula from another sheet, but am having trouble following exactly what it's doing. Any help is GREATLY appreciated!

    Code:
    = RIGHT(J2,LEN(J2)-FIND("*",SUBSTITUTE(J2," ","*",LEN(J2)-LEN(SUBSTITUTE(J2," ",""))))))
    Cell J2 contains the full user name, which is to be compared to another name value from another system which will contain a similar formula.

    THANK YOU!
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    findout the position of the space from the right side .
    From that position+1 read to the end for the last name.

    Comment

    • rpicilli
      New Member
      • Aug 2008
      • 77

      #3
      Hi there.

      You can use the property lastindexof to find the last space and get the last word

      The example below show you how to get the last word typed in TextBox1 and put in Label1.Text

      I hope this help you.


      Code:
          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
              Me.Label1.Text = Me.TextBox1.Text.Substring(Me.TextBox1.Text.LastIndexOf(" ") + 1)
          End Sub

      Comment

      • JP Romano
        New Member
        • Oct 2008
        • 11

        #4
        Thanks a million for the help!

        Comment

        Working...