+ Reply to Thread
Results 1 to 6 of 6

Extracting a person's name from a string of text using IF/Else

  1. #1
    Registered User
    Join Date
    01-27-2021
    Location
    Male’ , Maldives
    MS-Off Ver
    Office 365
    Posts
    3

    Extracting a person's name from a string of text using IF/Else

    Hey, I need to extract a name from a string in a format of [Numbers with SC] [ Numbers with SC] [Name] [LOCATION] [Alphanumeric] (Eg: 63/12-3 218391/23457-1892 Adam Smith NEW YORK BL12938LR12). What I initially thought of doing was use a MID Function to remove the beginning numeric values and special characters from the string and then use a LEFT function to search for the Location and remove everything including and after the location. [=LEFT(C3,(FIND(" NEW YORK",C3,1)-1))].

    Issue is there's a lot of locations so I had to filter out each location then run the next location in the chain and repeat that process until all locations were accounted for. There has to be a faster way.

    My thoughts now is to use an IF/Else function where it searches for a Location from a list that I give it and IF it finds the location it runs the appropriate LEFT function. Else it moves onto the next location.

    Is this possible? If it is, is there a better/faster way? Thank you.

    Also I have almost no experience in coding or macros.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Extracting a person's name from a string of text using IF/Else

    This formula extracts two words (names) starting from the second space character to the forth space character.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If you had a three word name name like George Van Patten, it would only extract George Van.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    01-27-2021
    Location
    Male’ , Maldives
    MS-Off Ver
    Office 365
    Posts
    3
    Quote Originally Posted by AlphaFrog View Post
    This formula extracts two words (names) starting from the second space character to the forth space character.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If you had a three word name name like George Van Patten, it would only extract George Van.

    That sounds better than we what I’m doing already. Though, Im dealing with around 2-3 thousand names so I don’t think I’d be able to find out whether I got the full names of everyone.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Extracting a person's name from a string of text using IF/Else

    Will the LOCATION always be in caps as in your example data?

  5. #5
    Registered User
    Join Date
    01-27-2021
    Location
    Male’ , Maldives
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Extracting a person's name from a string of text using IF/Else

    Yes. The location is always in caps

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Extracting a person's name from a string of text using IF/Else

    The code below extracts the name between the second space character to the word in all caps.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Extracting text from a string
    By simonelvin in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-10-2014, 06:58 AM
  2. Extracting text from a string
    By AlexDeLara in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-26-2014, 04:41 AM
  3. Extracting numbers and text from inconsistent text/number formatted string
    By Brandivil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-25-2013, 01:46 PM
  4. [SOLVED] Extracting Text from a string of Text & Digits of variable length
    By hastex in forum Excel General
    Replies: 6
    Last Post: 06-06-2012, 09:11 AM
  5. Extracting text from a string
    By excelhelp18 in forum Excel General
    Replies: 1
    Last Post: 04-05-2012, 03:08 AM
  6. Extracting just the last name in a text string
    By braydon16 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-26-2008, 11:33 AM
  7. Extracting just the last name in a text string
    By braydon16 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-06-2008, 08:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1