To extract numbers from text in Excel, you can use a formula that separates digits from surrounding characters and returns the result as a number.
The best approach depends on whether the text contains one number, several numbers, decimals, or other symbols.
Extract digits from text in Excel 365
In Microsoft 365 and Excel 2021 or later, dynamic array functions make it possible to examine each character in a cell and keep only the digits.
If A2 contains Order 5842 complete, enter this formula in B2:
=LET(t,A2,c,MID(t,SEQUENCE(LEN(t)),1),n,TEXTJOIN("",TRUE,IFERROR(c*1,"")),IF(n="","",VALUE(n)))
The expected result is the number 5842.
The formula works character by character: MID returns each character, SEQUENCE supplies the character positions, and multiplication by 1 tests whether each character is numeric.
TEXTJOIN combines the digits that pass that test, while VALUE converts the joined text into a numeric value.
Copy the formula down to process additional rows.
If a cell contains no digits, the formula returns a blank.
If you prefer a zero in that case, replace "" in the final IF with 0.
Keep a decimal point and a negative sign
The digit-only formula drops punctuation, so Balance -18.75 USD would become 1875.
To preserve a leading minus sign and decimal point, use this formula when each cell contains one number formatted with a period as the decimal separator:
=LET(t,A2,c,MID(t,SEQUENCE(LEN(t)),1),n,TEXTJOIN("",TRUE,IFERROR(IF((c="-")+(c="."),c,c*1),"")),IFERROR(VALUE(n),""))
For Balance -18.75 USD, the expected result is -18.75.
This formula keeps every hyphen and period it finds, so it is intended for text where those symbols occur only as part of the number.
It does not distinguish a thousands separator from a decimal separator.
For example, a value written as 1,234.50 needs a formula that also retains the comma, or a cleanup step suited to your regional number format.
Excel interprets decimal and thousands separators according to the system and workbook settings.
If your data uses a comma as the decimal mark, replace the period check with a comma and confirm that VALUE recognizes the resulting text in your locale.
Extract the first number with a regular expression
Some Microsoft 365 builds provide REGEXEXTRACT.
Where it is available, this is a concise way to return the first number from a text string.
For a positive integer or decimal using a period as its decimal mark, use:
=IFERROR(VALUE(REGEXEXTRACT(A2,"[0-9]+(?:\.[0-9]+)?")),"")
If A2 contains Temperature: 21.5 C; target: 24 C, the expected result is 21.5.
The pattern matches one or more digits, with an optional decimal portion.
To accept an optional negative sign, use:
=IFERROR(VALUE(REGEXEXTRACT(A2,"-?[0-9]+(?:\.[0-9]+)?")),"")
REGEXEXTRACT availability depends on the Excel version and update channel.
If Excel returns a #NAME? error for that function, use the LET and dynamic-array formula above if supported, or use a legacy-compatible method.
Extract multiple numbers from one cell
If a cell contains several numbers, a formula designed to collect all digits into one result will merge them.
For example, extracting all digits from Box 12, shelf 4 produces 124, which does not preserve the original two values.
Where REGEXEXTRACT supports returning multiple matches, use a pattern that matches each integer or decimal:
=REGEXEXTRACT(A2,"[0-9]+(?:\.[0-9]+)?",1)
For Box 12, shelf 4, the expected results spill into adjacent cells as 12 and 4.
Make sure the cells to the right are empty so the spilled results have room.
Function support and the optional match argument may vary by Excel build; consult Excel's function autocomplete or documentation for your version.
Options for older Excel versions
Excel 2019, 2016, and earlier do not have the same dynamic-array functions as Microsoft 365.
A classic array formula can extract digits from a cell, but it may require special entry depending on the version.
This example handles digits only:
=SUMPRODUCT(MID(0&A2,LARGE(INDEX(ISNUMBER(--MID(A2,ROW($1:$99),1))*ROW($1:$99),0),ROW($1:$99))+1,1)*10^(ROW($1:$99)-1))
This formula is designed for text up to 99 characters and joins the digits into one number.
If the text contains no digits, it returns an error; wrap it in IFERROR(...,"") if a blank is suitable.
In some older Excel versions, formulas that use array calculations must be confirmed with Ctrl+Shift+Enter instead of Enter.
It also ignores signs and decimal marks, so it is appropriate only when the digits can safely be combined.
For a more maintainable workflow, use Power Query: select the data range, choose Data > From Table/Range, then transform the text column to keep the characters that are digits.
The exact menu wording can differ by Excel version.
Power Query is useful for repeated imports because you can refresh the transformation when the source data changes.
Common problems and edge cases
- Leading zeros: Converting a result to a number removes leading zeros.
If values such as postal codes or product IDs must retain them, return text and omitVALUE. - Several separate values: A formula that joins all digits cannot tell where one number ends and another begins.
Use a pattern-based method that returns separate matches or split the text based on its labels or delimiters. - Thousands separators: Commas, spaces, or periods may have different meanings across locales.
Normalize separators before converting text to a number. - Dates and codes: A string such as
2026-03-08contains digits, but extracting them does not create a date.
Parse dates with date-aware functions or Power Query. - Long numeric strings: Excel stores numbers with limited precision.
For long account or tracking identifiers, preserve the extracted value as text rather than converting it withVALUE. - No matching number: Wrap extraction or conversion in
IFERRORwhen a blank is a suitable result, and consider whether a blank could hide unexpected source data.
Choose the formula based on the shape and meaning of the source text.
For a single whole number in a mixed string, the digit-only formula is usually sufficient; for decimals, negative values, or multiple matches, preserve the relevant separators and check that the method matches your Excel version and regional settings.