Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Extract Email ID From A List Of Sentences

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    22
    Rep Power
    0

    Extract Email ID From A List Of Sentences

    Hey all. I was in this forum a year or so ago when Rick Rothstein saved my life with a VBA code that extracts email addresses from text in Excel files. See http://www.excelfox.com/forum/f2/vba...92/index3.html.

    Well, it's been working swimmingly until now. I've found The Cursed File. It's a file of data which Rick's code cannot extract data from no matter what format I save it in.

    See the attached file. I created it from scratch, applied Rick's code, and in the top line I pasted a line of data from The Cursed File. As you can see, the code does not extract the email.
    Underneath, I created test data. As you can see, the code works.
    On the final line, I pasted in some similar data from another file. Code works.

    What gives? I've noticed that when I delete about two-thirds of the text from the Cursed Data line in D1, the code works. But that's no fix at all.


    Thanks much in advance.
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    An alternative:

    Code:
    Function F_snb(c00)
       F_snb = Trim(Replace(Join(Filter(Split("|~" & Join(Filter(Split(c00), "@"), "|~"), "|"), "~@", False)), "~", ""))
    End Function

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    22
    Rep Power
    0
    Hey SNB, thanks for your input. I tried running your VBA instead of Rick's on the test xl attached as well as the original Cursed File but all it gives me is #NAME?

    Did you try your VBA on my test file?

  4. #4
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    Yes I tested it on your file.

    Do you know where to store a UDF and how to call a UDF ?

  5. #5
    Junior Member
    Join Date
    Jun 2013
    Posts
    22
    Rep Power
    0
    I don't. I'm not far past Excel novice status. Can you explain?

  6. #6
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    dunndealpr,

    Just copy SNB's code above, and paste it in the same module after Rick's code (after the last line of course).

    The instead of =GetEMailAddress(D1), use =F_snb(D1)

    Of course you can rename the name of the function to anything you want if needed.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  7. #7
    Junior Member
    Join Date
    Jun 2013
    Posts
    22
    Rep Power
    0
    wow! it worked! thank you.

    1. why didn't Rick's code alone work on these particular contacts? Rick's code has worked time and time again for me. Even when I pasted the text into a textpad then back into a brand new excel file they still wouldn't work, even alongside other similar data that Rick's code was handling just fine. It confounds me.

    2. Will this combination of Rick's code and the new code work across the board for all such data? Or just in this instance where Rick's code isn't doing the trick for whatever weird reason?

    Thanks guys.

  8. #8
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    It was rather meant as a replacement of Rick's code.

  9. #9
    Junior Member
    Join Date
    Jun 2013
    Posts
    22
    Rep Power
    0
    so that code works on the document alone for you? without Rick's code first?

  10. #10
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    Yes, it does. It's the only code you need.

Similar Threads

  1. VBA To Extract Email Address From Text
    By dunndealpr in forum Excel Help
    Replies: 43
    Last Post: 06-05-2019, 03:56 PM
  2. Replies: 1
    Last Post: 07-26-2013, 01:54 AM
  3. Replies: 6
    Last Post: 05-25-2013, 07:36 PM
  4. Extract Email Text to Excel
    By bcloring in forum Excel Help
    Replies: 5
    Last Post: 12-14-2012, 04:10 AM
  5. Extract Unique Values List
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 4
    Last Post: 03-06-2012, 09:51 PM

Posting Permissions

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