How to extract numbers from a cell in Excel
Whether you need digits out of a product code, an order ID, or a free-text field, here are the formulas (old and new), the Power Query route, and what to do when the data isn't actually in Excel yet.
"Pull the numbers out of this column" is one of those Excel tasks that's been a one-liner since 2022 if you have the right version, and a 100-character formula if you don't. Here's the full picture.
Microsoft 365: REGEXEXTRACT
If you're on a current Microsoft 365 build, REGEXEXTRACT was added in 2024 and makes this trivial:
=REGEXEXTRACT(A1, "\d+")
That returns the first run of digits in the cell. To get all numbers concatenated, use TEXTJOIN with the array form:
=TEXTJOIN("", TRUE, REGEXEXTRACT(A1, "\d+", 1))
Excel 2021 and 365 (no REGEX): TEXTJOIN + SEQUENCE
Before REGEXEXTRACT, the canonical formula walks every character with SEQUENCE:
=TEXTJOIN("", TRUE, IFERROR(MID(A1, SEQUENCE(LEN(A1)), 1) * 1, ""))
This pulls digits out of any cell, regardless of position. To keep them as a number, wrap the whole thing in VALUE().
Older Excel: ROW(INDIRECT)
If you're stuck on Excel 2016 or earlier, the SEQUENCE call needs to be replaced with the ROW(INDIRECT) trick, and the formula needs Ctrl+Shift+Enter to evaluate as an array:
{=TEXTJOIN("", TRUE, IFERROR(MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1) * 1, ""))}
Power Query
For repeatable cleanup on a column or whole table, Power Query is more maintainable than nested formulas. Use the "Extract → Text Between Delimiters" transformations or write a custom column with Text.Select:
Text.Select([Column1], {"0".. "9"})
This keeps only the digit characters. The advantage over a formula is it survives copy-paste, it documents itself in the query steps, and it's faster on large datasets.
Numbers before a decimal
If you want the integer part of a numeric value, INT() or TRUNC() is the right tool. If you want it from a text cell that contains a decimal number, combine LEFT and FIND:
=LEFT(A1, FIND(".", A1) - 1)
Google Sheets
Google Sheets has had REGEXEXTRACT for years and the syntax is the same:
=REGEXEXTRACT(A1, "\d+")
For all digits in the cell:
=REGEXREPLACE(A1, "[^0-9]", "")
When the data isn't in Excel yet
All of the above assumes the text is already in a cell. If you're copying numbers out of PDFs or screenshots into Excel by hand, you're solving the wrong problem — the bottleneck is the OCR, not the formula. ExtractFox handles PDFs and images directly into structured spreadsheet output, so by the time it reaches Excel the numbers are already in their own columns.