Skip to content
xlsoffice. All Rights Reserved
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Lookup and Reference Examples

  • How to get address of last cell in range in Excel
  • How to use Excel VLOOKUP Function
  • How to get address of first cell in range in Excel
  • How to calculate two-way lookup VLOOKUP in Excel Table
  • How to get relative row numbers in a range in Excel

Data Analysis Examples

  • How to conditionally sum numeric data in an Excel table using SUMIFS
  • How to count table rows in Excel
  • How to Create One and Two Variable Data Tables in Excel
  • How to Create Gantt Chart in Excel
  • Conditional Formatting Icon Sets Examples in Excel

Data Validation Examples

  • Data validation must not exist in list
  • Prevent invalid data entering in specific cells
  • Excel Data validation require unique number
  • How To Create Drop-down List in Excel
  • Excel Data validation no punctuation

How to get top level domain (TLD) in Excel

by

To extract the top level domain (called “TLD”)  from a list of domain names or email addresses, you can use a rather complex formula that uses several functions. In the formula below, domain represents a domain or email address in normal “dot” syntax.

Formula

=RIGHT(domain,LEN(domain)-FIND("*",SUBSTITUTE(domain,".","*",
LEN(domain)-LEN(SUBSTITUTE(domain,".","")))))

Explanation

In the example, the active cell contains this formula:

=RIGHT(B4,LEN(B4)-FIND("*",SUBSTITUTE(B4,".","*",LEN(B4)-LEN(SUBSTITUTE(B4,".","")))))

How the formula works:

At the core, this formula uses the RIGHT function to extract characters starting from the right.

The other functions in this formula just do one thing: they figure out how many characters need to be extracted.

Worked Example:   How to extract word containing specific text in Excel

At a high level, the formula replaces the last dot “.” in the domain with an asterisk “*” and then uses FIND to locate the position of the asterisk. Once the position is known, the RIGHT function can extract the TLD.

You may wonder how the formula knows to replace only the last dot?

This is the clever part of the formula.

The key is this part:

SUBSTITUTE(B4,".","*",LEN(B4)-LEN(SUBSTITUTE(B4,".","")))

which does the actual replacement of the last dot with “*”.

The trick is that SUBSTITUTE has a forth (optional) argument that specifies which “instance” of the find text should be replaced. If nothing is supplied for this argument, all instances are replaced. However, if, say the number 2 is supplied, only the second instance is replaced.

Worked Example:   Join cells with comma in Excel

So, the formula needs to figure out which instance to replace, which is done here:

LEN(B4)-LEN(SUBSTITUTE(B4,".",""))

The length of the domain without any dots is subtracted from the full length of the domain. The result is the number of dots in the domain.

In the example name in B4, there are two dots in the domain, so the number 2 is used as in the instance number:

SUBSTITUTE(B4," ","*",2)

This replaces only second dot with “*”. The name then looks like this:

Worked Example:   Split numbers from units of measure in Excel

“www.domain*com”

The FIND function then takes over to figure out exactly where the asterisk is in the text:

FIND("*", "www.domain*com")

The result is 11 (the * is in the 11th position) which is subtracted from the total length of the domain:

LEN(B4)-11

Since the name is 15 characters, we have:

14-11 = 3

Finally, the number 3 is used by RIGHT like so:

=RIGHT(B4,3)

Which results in “com”

So there you have it. That’s how this formula extracts only the top level domain from a full domain name or email address.

Post navigation

Previous Post:

How to get page from URL in Excel

Next Post:

How to strip protocol and trailing slash from URL in Excel

Leave a Reply Cancel reply

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

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others
  • Get position of 2nd 3rd and more instance of character in Excel
  • Remove leading and trailing spaces from text in one or more cells in Excel
  • Get last name from name with comma — Manipulating NAMES in Excel
  • Extract middle name from full name — Manipulating NAMES in Excel
  • Remove unwanted characters in Excel
  • How to calculate project start date based on end date in Excel
  • Display Days until expiration date in Excel
  • How to calculate working days left in month in Excel
  • Get month from date in Excel
  • EOMONTH function: Description, Usage, Syntax, Examples and Explanation
  • Calculate cumulative loan interest in Excel
  • SLN function: Description, Usage, Syntax, Examples and Explanation
  • ISPMT function: Description, Usage, Syntax, Examples and Explanation
  • ODDLPRICE function: Description, Usage, Syntax, Examples and Explanation
  • RATE function: Description, Usage, Syntax, Examples and Explanation
Acronyms, Abbreviations, Initialism & What They Stand For
© 2021 xlsoffice. All Rights Reserved | Teal Smiles