Both approaches are explained below.

TEXTAFTER with TEXTBEFORE

The formula in the worksheet shown uses theTEXTAFTERandTEXTBEFOREfunctions to extract domain names from URLs.

With the text “https://exceljet.net/formulas/" in cell B5, TEXTAFTER returns “exceljet.net/formulas/”.

Extracting the domain from a URL in older versions of Excel

TEXTBEFORE locates the single forward slash “/” and returns all previous text.

The final result is the domain “exceljet.net”.

with an empty string ("").

Extracting the domain from a URL in older versions of Excel

If “www.”

is not found, SUBSTITUTE returns the original result.

The LEFT function then extracts 21 characters from the URL, starting at the left.

Extracting the domain from a URL in older versions of Excel

The result is the domain name with a trailing slash, “https://exceljet.net/".

“https://") in place.

This is actually a hack to keep things simple.

Extracting the domain from a URL in older versions of Excel

Using LEN to providenum_charsis a simple way to give MID a number that is always large enough.

For example, =LEFT(“apple”,3) returns “app”.

When the text is not found, FIND returns a #VALUE error.

Extracting the domain from a URL in older versions of Excel

Excel formula: Create email address from name

Excel formula: Get domain from email address

Excel formula: Get name from email address

Excel formula: Get top level domain (TLD)

Excel formula: Remove protocol from URL

Excel TEXTAFTER function

Excel TEXTBEFORE function

Excel LEFT function

Excel FIND function