+ Reply to Thread
Results 1 to 9 of 9

Extract part of cell contents

  1. #1
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Extract part of cell contents

    Hello all

    Lets say I have a column with each cell containing a bunch of emails, delimited with #, like this:
    [email protected]#something...domdomain5.com

    There is no specific order in the emails and I am only interested in emails with a specific domain (after the @), in this case, the "@correctdomain.com" emails, ie the [email protected] email.

    So in short, I would like to extract the @correctdomain.com emails from column A to Column B, if any exist, as this:
    2019-02-16_18-52-33.png

    Is there a clever way to do this, or is it just the hard way with multiple nested IF's, FIND's, LEFT's, IFERROR etc?

    Thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Extract part of cell contents

    Please try at B2 and drag down

    =IFERROR(LOOKUP(,-SEARCH("correctdomain",MID(SUBSTITUTE(A2,"#",REPT(" ",300)),ROW($A$1:$A$10)*300-299,300)),TRIM(MID(SUBSTITUTE(A2,"#",REPT(" ",300)),ROW($A$1:$A$10)*300-299,300))),"")
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Extract part of cell contents

    Thank you very much Bo_Ry - this does seems to do the trick and I can use it.

    In my actual setup I do have around 8.000 rows, not starting from row 1, and for some reason it does not work if I change $A$1:$A$10 in the code to $A$3000:$A$11000. It only works if it starts at $A$1 or if I do the whole column like A:A. So it does take a very very long time to calculate (like 10 minutes).

    Would naturally prefer if I could make the formula less time consuming, but as I said, it works as intended and in lack of something faster I can use it

    So again, thanks and I really do appreciate your effort!

    I will however keep the thread open for a couple days, in case anyone else should have a more efficient solution.

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Extract part of cell contents

    No need to change $A$1:$A$10, ROW($A$1:$A$10) generate number 1 to 10 which I assume maximum no of # sign in 1 cell
    depend on maximum no of # you may change to ROW($A$1:$A$20)

    Formula at B3000 would be

    =IFERROR(LOOKUP(,-SEARCH("correctdomain",MID(SUBSTITUTE(A3000,"#",REPT(" ",300)),ROW($A$1:$A$20)*300-299,300)),TRIM(MID(SUBSTITUTE(A2,"#",REPT(" ",300)),ROW($A$1:$A$20)*300-299,300))),"")

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Extract part of cell contents

    Hi Imbizile,

    Ten minutes is a long time to wait. I think this is a 2 second problem, using Power Query. Here is how to do it....

    1. Remove all those blank rows in your data. You can delete them or sort and put them on the bottom.
    2. Click on any cell in column A (remove column B from the beginning) in your data.
    3. Click on the Data Tab and then on From Table/Range in the Get & Transform Data group
    4. This pulls it into the Power Query Editor and the fun begins.
    5. Next Split your data using the "#" character.
    6. now you need a column to UnPivot your data around so Add an Index Column
    7. Select the Index column and UnPivot Other Columns
    8. Remove Columns that are no longer needed
    9. Then Remove Rows that are Duplicate
    10. Sort the data by email names if you desire
    11. Load the result back into your Excel workbook.

    Easy Peasy!!! and it should take about a second to perform. See the attached...

    PQ to Extract Email Addresses.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  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 part of cell contents

    Try this
    Enter in B2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Extract part of cell contents

    @Bo_Ry, I totally misunderstood that ROW($A$1:$A$10) thing, I changed it back and now its runs very fast - we are talking seconds now!

    @AlKey, this even seems a little more efficient, so I think this is what I will end up using

    @MarvinP, yes, I am aware of the powers in PQ, just never really had the time to look much into it - I will definitely look into you solution at a later point and get familiar with it. The above solutions work in my setup for now.

    I thank each and everyone one of you for your solutions and effort!

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,812

    Re: Extract part of cell contents

    It's worth investing a bit of time in learning PQ: I am rebuilding many of my workbooks to use it instead of processor-hungry array formulae. Gil Raviv's latest book on PQ is worth getting.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: Extract part of cell contents

    Thanks AliGW, I will note that book down.

+ 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. Using cell contents as part of a VBA formula
    By olieshmade1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2015, 10:33 AM
  2. [SOLVED] Removing a part of the contents of a cell
    By alyaahmed in forum Excel General
    Replies: 11
    Last Post: 03-15-2014, 12:42 PM
  3. Cell Contents as Part Of Formula
    By outthere in forum Excel General
    Replies: 2
    Last Post: 07-23-2010, 01:47 PM
  4. function to get specified part of a cell contents
    By mieliepap in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-29-2010, 10:09 PM
  5. [SOLVED] Can I use cell contents as part of a formula?
    By Brian Rhodes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 12:05 AM
  6. Can I use cell contents as part of a formula?
    By Brian Rhodes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-05-2005, 11:05 PM
  7. [SOLVED] Can I use cell contents as part of a formula?
    By Brian Rhodes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-05-2005, 10:05 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