+ Reply to Thread
Results 1 to 12 of 12

Extract matching first name from unformatted email addresses

  1. #1
    Registered User
    Join Date
    04-02-2015
    Location
    New York, NY
    MS-Off Ver
    2013
    Posts
    5

    Question Extract matching first name from unformatted email addresses

    Hello,

    I have a long list of email addresses, all in random formats (they are not your standard [email protected]).

    I also have a list of 5k first names.

    The formula/macro needs to search each email address for a matching first name from 5k list and return the matching name. The logic is pretty straightforward:

    1. Return a value if the email address STARTS with one of the names in the list of 5k names. For example:
    The email "[email protected]" should return "Chris" but "[email protected]" shouldn't return anything.
    2. In cases where more than one match exists, return the longest match. For example:
    The email "[email protected]" would technically match with "dan", "daniel", and "danielle". In these cases, "Danielle" should be returned since it is the longest match.
    3. If there is no match, the macro shouldn't return anything.

    I tried accomplishing this using an Excel formula and got pretty far, but can't get it to search from the beginning of the email address. I upoaded my spreadsheet here:

    https://drive.google.com/file/d/0B8J...ew?usp=sharing

    Any ideas on how to fix my formula? I'm also open to a macro if you think that's a better solution.

    Your help is greatly appreciated!!

    Thanks,
    Glenn
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Extract matching first name from unformatted email addresses

    Try replacing your formula (B2) with this one and copy down...
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-02-2015
    Location
    New York, NY
    MS-Off Ver
    2013
    Posts
    5

    Thumbs up Re: Extract matching first name from unformatted email addresses

    Quote Originally Posted by jhren View Post
    Try replacing your formula (B2) with this one and copy down...
    Please Login or Register  to view this content.
    Thanks jhren, that seemed to do the trick! However, I noticed some inconsistencies with some of the email addresses. Here are two examples where the formula returns a name when it shouldn't:


    [email protected] Returns "Madonna"
    [email protected] Returns "Riva"

    I've updated the spreadsheet with your formula and both of these corner cases (see attached).
    Email List Elance Project.xlsx

    Any ideas on how to fix this?

    Thanks,
    Glenn

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Extract matching first name from unformatted email addresses

    hi Glenn. a different approach:
    =IFERROR(VLOOKUP(REPLACE(LEFT(A2,FIND("@",A2)-1),FIND(".",A2),100,""),'list of first names'!A:A,1,0),"")

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  5. #5
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Extract matching first name from unformatted email addresses


  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract matching first name from unformatted email addresses

    Somewhat similar to what benishiryo has offered but a little bit shorter

    =IFERROR(VLOOKUP(LEFT(A2,FIND("@",SUBSTITUTE(A2,".","@"))-1),'list of first names'!A:A,1,),"")
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  7. #7
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Extract matching first name from unformatted email addresses

    What do you expect for 'chrisjones@"?

  8. #8
    Registered User
    Join Date
    04-02-2015
    Location
    New York, NY
    MS-Off Ver
    2013
    Posts
    5

    Re: Extract matching first name from unformatted email addresses

    Quote Originally Posted by benishiryo View Post
    hi Glenn. a different approach:
    =IFERROR(VLOOKUP(REPLACE(LEFT(A2,FIND("@",A2)-1),FIND(".",A2),100,""),'list of first names'!A:A,1,0),"")
    Thanks for the reply benishiryo. Unfortunately this won't work because my email addresses are all in different formats (the majority of them are not [email protected], and frankly can be any format imaginable)

    So far, jhren's solution has come the closest to solving my problem:

    Please Login or Register  to view this content.
    However, there are some cases where it doesn't work and I can't figure out why.

    Any ideas?

    Thanks!
    G

  9. #9
    Registered User
    Join Date
    04-02-2015
    Location
    New York, NY
    MS-Off Ver
    2013
    Posts
    5

    Re: Extract matching first name from unformatted email addresses

    Quote Originally Posted by AlKey View Post
    Somewhat similar to what benishiryo has offered but a little bit shorter

    =IFERROR(VLOOKUP(LEFT(A2,FIND("@",SUBSTITUTE(A2,".","@"))-1),'list of first names'!A:A,1,),"")
    Hi Alkey - Unfortunately this won't work. See my reply to benishiryo.

  10. #10
    Registered User
    Join Date
    04-02-2015
    Location
    New York, NY
    MS-Off Ver
    2013
    Posts
    5

    Re: Extract matching first name from unformatted email addresses

    Quote Originally Posted by István Hirsch View Post
    What do you expect for 'chrisjones@"?
    Hi Istvan,

    The email "[email protected]" should return "Chris"

    Thanks,
    G

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract matching first name from unformatted email addresses

    Try this one.

    =IFERROR(IFERROR(VLOOKUP(LEFT(A2,FIND("@",SUBSTITUTE(A2,".","@"))-1),'list of first names'!A:A,1,),LOOKUP(10^308,SEARCH('list of first names'!$A$2:$A$5313,LEFT(A2,FIND("@",SUBSTITUTE(A2,".","@"))-1)),'list of first names'!$A$2:$A$5313)),"")

  12. #12
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Extract matching first name from unformatted email addresses

    See if this works for you. Made list into a Table and sorted. Also made it all lower case. Don't know if the lower case made any difference but that's where it ended up.

    Please Login or Register  to view this content.
    Note it is an array formula requiring Ctrl+Shift+Enter confirmation (as opposed to typical Tab, Enter, or click elsewhere)
    Attached Files Attached Files

+ 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. [SOLVED] Extract Email Addresses
    By amicman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-06-2013, 04:33 PM
  2. Extract email addresses from hyperlinks
    By artsy in forum Excel General
    Replies: 1
    Last Post: 11-10-2011, 09:37 AM
  3. Matching on Name to Phone/Email Addresses
    By caineslum in forum Excel General
    Replies: 1
    Last Post: 10-21-2011, 06:55 PM
  4. Extract Email Addresses From Excel
    By blacksunseven in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2007, 05:48 AM
  5. How to extract email addresses to new column
    By Inquirer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-06-2006, 04:30 PM

Tags for this Thread

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