# How to check if a cell contains a number in Excel

Look for each digit 0 to 9 and count the hits: =COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A2))>0. In Google Sheets use =REGEXMATCH(A2,"\d").

**Excel:** `=COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A2))>0` (Every current version)

**Google Sheets:** `=REGEXMATCH(A2,"\d")`

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Username | Has a digit? |
| mlopez |  |
| joneil2 |  |
| msmith |  |
| l3riksen |  |
| cokafor |  |
| atanaka99 |  |

Formula in B2, filled to B7: `=COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A2))>0`

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

## How it works

FIND with the list `{0,1,…,9}` searches for each digit and returns ten results: a position where the digit appears, an error where it doesn't. COUNT counts only the positions, so anything above 0 means the text contains a digit.

In Google Sheets, `\d` is the pattern for any digit.

## Other ways

- `=SUMPRODUCT(--ISNUMBER(FIND({0,1,2,3,4,5,6,7,8,9},A2)))>0`: The same test with SUMPRODUCT, a common form in older workbooks.

## Common mistakes

- `ISNUMBER(A2)` answers a different question: whether the whole cell is a number, not whether the text contains a digit.
- In Google Sheets, the FIND version needs ARRAYFORMULA to search for all ten digits; REGEXMATCH doesn't.

## Questions

**How do I check that the cell contains only digits?**

In Excel 365 use `=REGEXTEST(A2,"^\d+$")`, in Google Sheets `=REGEXMATCH(A2,"^\d+$")`.

**How do I extract the numbers?**

Use `=--CONCAT(IFERROR(MID(A2,SEQUENCE(LEN(A2)),1)*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-contains-a-number
