Exceljet

Quick, clean, and to the point

Get domain name from URL

Excel formula: Get domain name from URL
Generic formula 
=LEFT(url,FIND("/",url,9))
Explanation 

If you want to extract the domain name from a complete URL, you can do so with a formula that uses the the LEFT and FIND functions. In the generic form above, url is the the URL you are working with.

In the example, we are using this formula:

=LEFT(B4,FIND("/",B4,9))

Here's how the formula works:

B4 contains the URL: "https://exceljet.net/keyboard-shortcuts"

At the core, this formula is extracting characters from the URL, starting from the left, and using the FIND function to figure out how many characters to extract.

First, FIND locates the "/" character in the URL, starting at the 9th character. This is the "clever" part of the formula. URLs begin with something called a "protocol" which looks like this:

http://
https://
ftp://
sftp://

and so on. By starting at the 9th character, the protocol is skipped, and the FIND function will return the location of the 3rd instance of "/" (the first instance after the double slash in the protocol).

In this case, the third instance of "/" is the 21st character in the URL, so FIND returns the number 21.

The LEFT function then extracts 21 characters from the URL, starting at the left. The result is the domain name with a trailing slash.

If you want to get the domain name without a trailing slash, just subtract the number 1 from the the result of FIND like so:

=LEFT(B4,FIND("/",B4,9)-1)
Author 
Dave Bruns

Excel Formula Training

Formulas are the key to getting work done in Excel. In this step-by-step training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Start building valuable skills with Excel formulas today. Learn more.

Thank you very much for this resource. I've been visiting your site here-and-there for over a year now and I want to thank you for all of the valuable knowledge that you and your team have shared. - Neil
Excel foundational video course
Excel Pivot Table video training course
Excel formulas and functions video training course
Excel Shortcuts Video Course
Excel Charts video training course