To pull the domain out of an email address, use =RIGHT(A2,LEN(A2)-SEARCH("@",A2)). SEARCH finds the position of the "@", LEN gives the total length of the address, and subtracting one from the other tells RIGHT how many characters to grab from the end.
In Excel 365, =TEXTAFTER(A2,"@") does the same job in one step. If you want just the name without the extension — “gmail” instead of “gmail.com” — use =TEXTBEFORE(TEXTAFTER(A2,"@"),"."). And to get the part before the @ instead, swap to =LEFT(A2,SEARCH("@",A2)-1).
Let’s say you have a list of email IDs, and now you want to extract the domain for each ID. In Excel, a simple formula can extract the domains. And in this tutorial, we will learn to write this formula.

=RIGHT(A2,LEN(A2)-SEARCH("@",A2))
The above formula helps you to get the domain from the email. To understand this formula, you need to split it into three parts.
Get the Position of @ from the Email
First, you need to get the position of the “@” in the email ID. As you know, in an email ID, the domain starts after the “@”. For this, you need to use the SEARCH function.

In the above example, you have got 6 in the result, meaning “@” is the 6th character in the email.
Count the Length of the Domain
Next, get the count of characters from the domain part of the email. And for this, you need to use the LEN function to get the count. And then deduct the position of the “@” from it.

In the snapshot, we have the domain “yahoo.ca”, which has 8 characters, and that’s what you have got in the result.
Extract Domain
Now you know the length of the domain in the email ID. So, you can use the RIGHT function to get the domain from the right side of the cell.

RIGHT uses the count of domain characters and gets them from the end of the email ID.
Handle Blank Cells and Extra Spaces
If a cell is blank or doesn’t have an “@”, SEARCH can’t find it and the formula returns #VALUE!. Wrap the formula in IFERROR to show a blank instead:
=IFERROR(RIGHT(A2,LEN(A2)-SEARCH("@",A2)),"")
And if the email IDs have spaces at the start or end (common with copied data), use TRIM inside the formula, so the spaces don’t end up in the domain:
=RIGHT(TRIM(A2),LEN(TRIM(A2))-SEARCH("@",TRIM(A2)))
Get the Domain with TEXTAFTER
In Microsoft 365 (and Excel 2024), TEXTAFTER does the same thing in a much shorter formula. It returns everything after the “@”:
=TEXTAFTER(A2,"@")
You can also use Flash Fill without any formula: type the first domain next to the first email, then press Ctrl + E, and Excel fills the rest following the same pattern.
Get the Domain from a URL
If you have website addresses instead of email IDs, the domain sits between “//” and the next “/”. The following formula takes that part out, and it also works when the URL has no “/” after the domain:
=MID(A2,FIND("//",A2)+2,FIND("/",A2&"/",FIND("//",A2)+2)-FIND("//",A2)-2)
For https://www.excelchamps.com/formulas/, it returns www.excelchamps.com. To remove the “www.” as well, wrap the formula in SUBSTITUTE(…,”www.”,””). And in Microsoft 365, this shorter formula does the same:
=TEXTBEFORE(TEXTAFTER(A2,"//"),"/",,,1)
Frequently Asked Questions
How do I get the domain name without .com?
Once you have the domain in a cell (like B2), take everything before the first dot with LEFT and FIND. For “yahoo.ca”, this returns “yahoo”:
=LEFT(B2,FIND(".",B2)-1)
How do I get the user name from an email ID?
Use LEFT with the position of “@” minus 1, which takes everything before the “@”:
=LEFT(A2,SEARCH("@",A2)-1)
Why does the formula return #VALUE!?
The cell has no “@” (or it’s blank), so SEARCH returns an error. Check the data, or use the IFERROR version shown above.
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.