# How to check if a cell ends with specific text in Excel

Compare the last characters with the ending: =RIGHT(A2,LEN($E$1))=$E$1 returns TRUE when A2 ends with the text in E1.

**Excel:** `=RIGHT(A2,LEN($E$1))=$E$1` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E |
| --- | --- | --- | --- | --- |
| Email | Company address? |  | Ends with | @northwind.example |
| lena.park@northwind.example |  |  |  |  |
| omar@gmail.example |  |  |  |  |
| p.shah@northwind.example |  |  |  |  |
| tom@northwind.example.net |  |  |  |  |
| INES@NORTHWIND.EXAMPLE |  |  |  |  |
| raj@contoso.example |  |  |  |  |

Formula in B2, filled to B7: `=RIGHT(A2,LEN($E$1))=$E$1`

Result: TRUE; FALSE; TRUE; FALSE; TRUE; FALSE

## 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.

## Other ways

- `=COUNTIF(A2,"*"&$E$1)>0`: 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".

## 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)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/check-if-cell-ends-with-specific-text
