How to check if a cell ends with specific text in Excel
Formula (Excel and Google Sheets)
=RIGHT(A2,LEN($E$1))=$E$1Compare the last characters with the ending: =RIGHT(A2,LEN($E$1))=$E$1 returns TRUE when A2 ends with the text in E1.
- Result on the example
- one result per row in
B2, filled down toB7 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in B2, filled down to B7. Change any input and the result updates, or edit the formula to experiment.
How it works
RIGHT takes as many characters from the end as the ending has, and = compares them with it, ignoring case. "tom@northwind.example.net" contains the domain but doesn't end with it, which is exactly the case a "contains" test gets wrong.
=RIGHT(A2,LEN($E$1))=$E$1ResultTRUE
A2"lena.park@northwind.example"The value in A2.
$E$1"@northwind.example"The value in E1.
LEN($E$1)18LEN: Number of characters.- text
$E$1"@northwind.example"
- text
RIGHT(A2,LEN($E$1))"@northwind.example"RIGHT: Characters from the end of text.- text
A2"lena.park@northwind.example" - num_chars
LEN($E$1)18
- text
RIGHT(A2,LEN($E$1))=$E$1TRUEThe = operator tests whether the two sides are equal.
In Google Sheets
The same formula works in Google Sheets: =RIGHT(A2,LEN($E$1))=$E$1. We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =COUNTIF(A2,"*"&$E$1)>0 | TRUE, FALSE, TRUE… | Wildcard version: "*@northwind.example" means anything followed by the domain. |
Common mistakes
- Trailing spaces in the data make every test fail. Use
RIGHT(TRIM(A2),LEN($E$1))on imported lists. - Checking with SEARCH or "*text*" instead finds the text anywhere, including "…example.net".
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Check if a cell ends with specific text
B2, return TRUE when the email ends with the text in E1 and FALSE otherwise. Fill down to B7.Questions
How do I check for one of several endings?
Combine tests with OR: =OR(RIGHT(A2,4)=".pdf",RIGHT(A2,5)=".docx").
How do I count the matching cells?
Use =COUNTIF(A2:A7,"*"&$E$1).
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.