Extracting domains from email addresses can help analyze data, filter company-specific emails, and organize them for marketing or security purposes. If you have a database of email addresses and you need to extract domains from them, Excel offers a few ways to do that easily and quickly.
Unlike other tools that require coding, Excel provides simple formulas and techniques that allow even non-technical users to extract domains with ease. In this post, we will show you how to get domain from email address in Microsoft Excel.
How to get domain from email address in Excel
To get domain from an email address in Excel, you may use the following methods:
- Use Excel functions
- Use the Text to Column feature
- Use the Flash Fill feature
Let us see this in detail.
1] Use Excel functions
If you have Excel 365, you may use the TEXTAFTER or TEXTSPLIT functions to extract domains from emails. These functions are also available in Excel for the web.
The TEXTAFTER function extracts everything after a specified delimiter, while the TEXTSPLIT function splits text into multiple parts based on a delimiter and returns them as an array.
Suppose we have a sample dataset of emails as shown in the below image:
To extract domains from these emails, we will use the TEXTAFTER function as follows:
Place the cursor in cell B2 and type the following function:
=TEXTAFTER(A2,"@")
Press the Enter key. The formula will extract the domain from the email in cell A2 and display it in cell B2.
Now place the cursor in cell B2, take it towards the bottom-right corner until it turns to a plus sign, and then drag it to cell B8. As the formula is copied down, it extracts the domains from each email and places them in the respective cells in column B.
Similarly, to use the TEXTSPLIT function, place your cursor in cell B2 and type the following:
=TEXTSPLIT(A2,"@")
Press the Enter key. The TEXTSPLIT function will split the email at the ‘@’ character and return the name and the domain in cells B2 and C2 respectively.
To extract only the domain, you may use the TEXTSPLIT function and the INDEX function together as follows:
INDEX(TEXTSPLIT(A2, "@"), 2)
If you have Excel 2021, 2019, or an older version, you will not have the TEXTAFTER and TEXTSPLIT available. In that case, you may use the MID & FIND or the RIGHT, LEN, & FIND functions together to extract domains from emails.
To use the MID & FIND functions, enter the following formula in cell B2:
=MID(A2, FIND("@", A2) + 1, LEN(A2))
To use the RIGHT, LEN, & FIND functions, enter the following formula in cell B2:
=RIGHT(A2, LEN(A2) - FIND("@", A2))
Both of the above formulas will produce the same result, extracting domains from email addresses in the given database.
2] Use the Text to Column feature
The Text to Columns feature in Excel allows you to split text from one column into multiple columns using a specified delimiter. You may use it to extract domains from emails in the following way:
Select the data range (if you do not have headers, you could select the entire column as well). For our sample data, we have selected the data range A2: A8. Now go to Data > Text to Columns in the Excel ribbon.
A Convert Text to Columns Wizard will appear. In the wizard, select Delimited and click Next. Check the Other box and enter ‘@’ as the delimiter. Click Next. Select column B in Destination and click Finish.
The command will break the emails into two parts (based on the specified delimiter ‘@’), input the first part in the destination column (i.e. column B), and the second part (the domains) in the adjacent column (i.e. column C).
3] Use the Flash Fill feature
Flash Fill is a feature that automatically detects patterns in your data and fills in the remaining cells accordingly. To use it to extract domains from your email addresses, you need to manually create a pattern.
Place your cursor in cell B2 and manually type just the domain (e.g., gmail.com). Similarly, type just the domain for the email in cell A3, in cell B3. Now place the cursor in cell B4 and press Ctrl + E to invoke Flash Fill.
Alternatively, go to the Data tab and select Flash Fill to extract domains from the rest of the emails automatically.
If Flash Fill is not working or isn’t available, go to File > Options > Advanced.
Under Editing options, ensure ‘Automatically Flash Fill‘ is checked.
Note:
- Flash Fill works based on patterns, so ensure your input format is consistent.
- Excel might not recognize the pattern if some emails contain spaces or special characters.
I hope you find this useful.
Read: How to extract Domain Names from URLs in Excel
How to find the domain of an email address?
A domain is the part of an email address that comes after the ‘@’ symbol. It identifies the email service provider or organization hosting the email. To find the domain, simply look at the part of the email address after the “@” symbol.
Read: AutoFill is not working in Excel.
How to sort by email domain in Excel?
To sort email addresses by domain name, insert a new column next to the email column and extract the domains using the TEXTAFTER() function. Select both columns and go to Data > Sort. Choose Sort by Column B (domain) > A to Z (Ascending) or Z to A (Descending). Click OK to apply changes.
Read Next: How to pull Data from another Sheet in Excel.