# How to extract a number from text in Google Sheets

Use REGEXEXTRACT with a number pattern and wrap it in VALUE: =VALUE(REGEXEXTRACT(A2,"-?\d[\d,]*\.?\d*")). It keeps decimals, thousands commas and minus signs.

**Google Sheets:** `=VALUE(REGEXEXTRACT(A2,"-?\d[\d,]*\.?\d*"))`

**Excel:** Excel 365 has REGEXEXTRACT too, and the same formula works there. In older versions, split around a known label with MID and FIND, or use Flash Fill (Ctrl+E).

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Note | Number |
| Weight: 12.5 kg |  |
| Paid $1,250.75 by card |  |
| Temp -4 C |  |
| Order 4471 shipped |  |
| Discount 15% |  |

Formula in B2, filled to B6: `=VALUE(REGEXEXTRACT(A2,"-?\d[\d,]*\.?\d*"))`

Result: 12.5; 1250.75; -4; 4471; 15

## How it works

The pattern reads: an optional minus, a digit, then any digits or commas, an optional decimal point and more digits. REGEXEXTRACT returns the first match as text ("1,250.75") and VALUE turns it into the number 1250.75.

## Other ways

- `=VALUE(REGEXREPLACE(A2,"[^\d.-]",""))`: Deletes everything that isn't a digit, a dot or a minus. Simpler, but only safe when each cell holds one number and no other dots or dashes.
- `=REGEXEXTRACT(A2,"-?\d[\d,]*\.?\d*")`: Without VALUE you get text. (Text such as "1,250.75" that won't add up in SUM.)

## Common mistakes

- REGEXEXTRACT returns only the first match. "2 boxes of 50" gives 2.
- A cell with no number returns #N/A. Wrap the formula in `IFERROR(…,"")`.
- REGEXEXTRACT needs text. If the cell holds a real number, use `TO_TEXT(A2)`.

## Questions

**How do I get the second number in the text?**

Skip the first one in the pattern: `=REGEXEXTRACT(A2,"\d+\D+(\d+)")`.

**How do I keep only the digits?**

Delete every non-digit: `=REGEXREPLACE(A2,"\D","")`.

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/extract-a-number-from-text-in-google-sheets
