dizzysoft

web development for search engine optimization

Excel formula to get domain name from URL

While doing SEO professionally I am always dealing with long lists of URLs. The best way to manage this is with Excel. Sometimes I need to take a list of URLs and parse them just to get the domain name.

For a while I kept re-writing the same formula each time I needed it. This time I’m going to share it- if only for myself, but someone else might be looking for it too.

Assuming that cell A2 contains the URL, if all you want is the domain name (with out the www), use this formula:
=IF(ISNUMBER(FIND("www.",A2)),MID(A2,FIND("www.",A2)+4,FIND("/",A2,9)-FIND("www.",A2)-4),MID(A2,FIND("//",A2)+2,FIND("/",A2,9)-FIND("//",A2)-2))

If you use a link report from MajesticSEO, who automatically removes the trailing slash at the end of homepages, you might want to use this version of the same code:
=IF(ISNUMBER(FIND("www.",A2)),MID(A2,FIND("www.",A2)+4,IF(ISNUMBER(FIND("/",A2,9)),FIND("/",A2,9),LEN(A2)+1)-FIND("www.",A2)-4),MID(A2,FIND("//",A2)+2,IF(ISNUMBER(FIND("/",A2,9)),FIND("/",A2,9),LEN(A2)+1)-FIND("//",A2)-2))

This should work whether or not the URL is HTTP or HTTPS. If a URL is the homepage of the website, this formula assumes that the homepage will end in a slash.

If you have a more efficient way to write this, or notice an error, please tell me in the comments.

Tags:

7 comments about Excel formula to get domain name from URL

  • Hey David,
    Don’t know if it’s more efficient or not but I just learned this trick the other day-

    I wanted a column of just domains and then a separate column for each sub folder so I pasted all my urls in one column, hit text to columns, delimited, other: /

    Once I had all that I also made pivot tables by subfolder and then subsequent categories under that, putting “subcategory” count as a value so I could see which were the main category sections and how big (and hence important?) each section of the site is.

    Now I can quickly eyeball the site layouts from my excel

  • Hi David,

    thanks for the formula, it works great for domain name with no subdomain. Would it be possible to have a formula to only get the host?

  • Hello David, Thanks for help us.

    But, this not work ini URL like This Tidak bisa untuk URL :
    htt*://somedomain.com/entries/order/site/www.otherdomain.com
    #VALUE!

    Thanks You

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Examples

Recent Comments

Topics