To pull only the digits out of a mixed value like “TPS1984“, use =TEXTJOIN("",TRUE,IFERROR(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)*1,"")). It splits the cell into single characters, multiplies each by 1 so letters become errors, IFERROR turns those into blanks, and TEXTJOIN glues the survivors back together.
On Excel 2019 it needs Ctrl+Shift+Enter; on 365 and 2021 a plain Enter works. The result is text, so add *1 at the end or wrap it in VALUE if you need a real number.
In Excel 365 there’s a one-line version that replaces all of this: =REGEXREPLACE(A1,"[^0-9]","") removes every non-digit, and =REGEXREPLACE(A1,"[^0-9]","")+0 returns it as a number. For a one-off cleanup with no formula, type the digits from the first row into the next column and press Ctrl+E for Flash Fill — it handles consistent patterns well.
And on Excel 2016 or earlier, where TEXTJOIN doesn’t exist, the SUMPRODUCT version is the fallback.
In Excel, you can use formulas to extract the number from a value with text and numbers combined. In the following example, we have used a formula to get 1984 from the value “TPS1984”.

Formula to Extract Numbers from a Text
=TEXTJOIN("",TRUE,IFERROR((MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)*1),""))
In this tutorial, we will understand this formula in detail. And to understand it, we need to split it into parts:
- First, we have the LEN function to get the count of characters in the value.

- After that, INDIRECT creates a reference to rows 1 to 7, using the 7 returned by LEN.

- Next, the ROW function uses that reference and returns an array of numbers starting from 1 and ending with 7.

- Now, MID uses this array and returns a new one with each character of the cell you referred to.

- Next, we have a simple multiplication to multiply the array by 1. With this, you get a new array where you will have #VALUE! Error for text values and numbers will stay intact.

- From here, the IFERROR function converts the error values into blank values.

- And in the end, TEXTJOIN will combine the values, and you’ll have only numbers in the result.

The above formula only works in Excel 2019 and later versions (including Microsoft 365), because it uses TEXTJOIN, which isn’t available in earlier versions. In Excel 2019, enter it with Ctrl + Shift + Enter, as it works with arrays.
If you want to see the value of a part of the formula, select that part in the formula bar and press the F9 key.
INDIRECT in this formula is a volatile function, which recalculates whenever you change any cell in the workbook. It can make your workbook a little slow.
But What IF I’m using an Earlier Version (2007, 2010,2013, 2016)
If you use one of the earlier versions, you must use a different formula, like the following:
=IF(SUM(LEN(A1)-LEN(SUBSTITUTE(A1, {"0","1","2","3","4","5","6","7","8","9"}, "")))>0, SUMPRODUCT(MID(0&A1, LARGE(INDEX(ISNUMBER(--MID(A1,ROW(INDIRECT("$1:$"&LEN(A1))),1))* ROW(INDIRECT("$1:$"&LEN(A1))),0), ROW(INDIRECT("$1:$"&LEN(A1))))+1,1) * 10^ROW(INDIRECT("$1:$"&LEN(A1)))/10),"")
=SUMPRODUCT(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))*ROW(INDIRECT("1:"&LEN(A1))),0),ROW(INDIRECT("1:"&LEN(A1))))+1,1)*10^ROW(INDIRECT("1:"&LEN(A1)))/10)
Both of the above formulas work fine with different kinds of values. I have tested them in the following way.

In cell A1 above, we have a complex value consisting of text, numbers, and symbols, and we have only numbers in the result.
Extract Numbers in Microsoft 365
In Excel for Microsoft 365, you can write the same formula in a shorter way with SEQUENCE instead of ROW and INDIRECT, and CONCAT instead of TEXTJOIN. It isn’t volatile, and you don’t need Ctrl + Shift + Enter:
=CONCAT(IFERROR(--MID(A1,SEQUENCE(LEN(A1)),1),""))
And with the new REGEXREPLACE function (Microsoft 365), you can remove everything that isn’t a digit in one step:
=REGEXREPLACE(A1,"[^0-9]","")
Things to Know About the Result
- Text or number: the TEXTJOIN, CONCAT and REGEXREPLACE formulas return the digits as text. Add — in front of the formula (like =–TEXTJOIN(…)) if you need a number you can calculate with.
- Leading zeros: the text result keeps them (“007Bond” gives “007”), but the SUMPRODUCT formula and — turn it into 7.
- Decimals and groups: all the formulas take every digit, so “12.5kg” gives 125 and “A12B34” gives 1234.
- Blank cells: the second SUMPRODUCT formula returns #REF! for a blank cell, so wrap it in IF(A1=””,””,…) when your data has blanks.
Extract Numbers without a Formula
If you only need fixed values, Flash Fill can do it. Type the number from the first cell in the next column, select the cell below it, and press Ctrl + E. Check the results, as Flash Fill guesses the pattern from your example.
Frequently Asked Questions
How do I remove the numbers and keep the text?
Reverse the IFERROR part, so it keeps the characters that aren’t numbers (Excel 2019 and later):
=TEXTJOIN("",TRUE,IF(ISERROR(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)*1),MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),""))
How do I extract a number only from the end of the text?
When the number is always at the end, like “TPS1984”, the formulas on this page work as they are. When the text has numbers in several places, they get joined together, so use Text to Columns or TEXTSPLIT to split the text first.
Why does SUM ignore my extracted numbers?
Because TEXTJOIN returns text, and SUM skips text. Add — in front of the formula to turn the result into a number.
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.