+ Reply to Thread
Results 1 to 13 of 13

Extract only certain part of text from a cell

  1. #1
    Registered User
    Join Date
    05-11-2013
    Location
    Malta
    MS-Off Ver
    Excel 2010
    Posts
    10

    Extract only certain part of text from a cell

    Hi guys, need your help!

    I have a list of over 500 000 webpages. Some of them are listed with http:// or https://, some have www. and some don't, some have .com/somethinghere and some don't.

    Webpages are different (from different domains, some are subdomains, etc).

    Thing is that I need a formula that would remove everything except the actual domain name. For example out of this:

    http://www.examplesite.com/whateverhere or;
    http://examplesite.site.com/verylong...ndomcharacters or
    examplesite.com/whatever

    I need to get this

    examplesite.com - no https, no forward slash, no www - plain domain name.

    I have found a temporary solution using text-to-cell with "/" as separator together with SUBSTIUDE, but going forward I will have much more such lists and I need to create template.

    Thank you!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract only certain part of text from a cell

    you could try this
    =LEFT(SUBSTITUTE(IF(ISNUMBER(SEARCH("//",A1)),MID(A1,SEARCH("//",A1)+2,255),A1),"www.",""),FIND("/",SUBSTITUTE(IF(ISNUMBER(SEARCH("//",A1)),MID(A1,SEARCH("//",A1)+2,255),A1),"www.",""))-1)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    05-11-2013
    Location
    Malta
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extract only certain part of text from a cell

    Hi Martin,

    Will try now, as soon as my file is done with recalculations. With such massive amount of data it takes up to 10 minutes sometimes...

    Just for you to know, how I did it in the first place. I made it in several steps:

    1. Used LEFT with Search to get rid of anything after third "/", ones that comes just after .com (or .any)

    2. Used Text to Cells where I used "/" as separator to split the whole URL (split http, name of the site and last /)

    3. used multiple SUBSTITUDE to get rid of www. and ww. (I had some sites with only two "ww")

  4. #4
    Registered User
    Join Date
    05-11-2013
    Location
    Malta
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extract only certain part of text from a cell

    Martin it works as a charm! Thank you my friend! Just one thing - where should I add another SUBSTITUTE in case if I have sites with "ww." instead of "www." ?

    Thanks a lot!

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract only certain part of text from a cell

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

  6. #6
    Registered User
    Join Date
    05-11-2013
    Location
    Malta
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extract only certain part of text from a cell

    Thank you very much!!!

  7. #7
    Registered User
    Join Date
    05-11-2013
    Location
    Malta
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extract only certain part of text from a cell

    Hi Martin,

    I noticed one thing: in case when domain name is missing last forward slash (ex -nameofsite.com instead of nameofsite.com/) then formula returns #value! error). If I add forward slash manually everything works. Can you help me with this one?

    Thanks!

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract only certain part of text from a cell

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

  9. #9
    Registered User
    Join Date
    05-11-2013
    Location
    Malta
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extract only certain part of text from a cell

    Quote Originally Posted by martindwilson View Post
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Hi Martin,

    it returns 0 now in all cases..

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract only certain part of text from a cell

    not for me
    Attached Files Attached Files

  11. #11
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Extract only certain part of text from a cell

    Another way:

    =IFERROR(LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"http://",""),"https://",""),"www.",""),FIND("/",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"http://",""),"https://",""),"www.",""))-1),SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"http://",""),"https://",""),"www.",""))

    This removes "www." "https://" and "http://" if there. then if the is anything after a "/" this will be removed.
    Say thanks, click *

  12. #12
    Registered User
    Join Date
    05-11-2013
    Location
    Malta
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Extract only certain part of text from a cell

    I think I got to the point where I made a mistake, will check again and let you know!

  13. #13
    Registered User
    Join Date
    05-11-2013
    Location
    Malta
    MS-Off Ver
    Excel 2010
    Posts
    10

    Thumbs up Re: Extract only certain part of text from a cell

    Quote Originally Posted by Dimitripros View Post
    I think I got to the point where I made a mistake, will check again and let you know!
    Found it, it was a lame one, I forgot to change the cell number...
    Thanks Martin, have a good day.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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