How to extract number only from text string in Excel?

Have you ever wanted to extract numbers only from a list of string in Excel? Here I introduce some ways for you to extract only numbers quickly and easily in Excel.

Method 1: Extract number only from text strings with formula

The following long formula can help you to extract only the numbers from the text strings, please do as this:

Select a blank cell where you want to output the extracted number, then type this formula: =SUMPRODUCT(MID(0&A5, LARGE(INDEX(ISNUMBER(--MID(A5, ROW(INDIRECT("1:"&LEN(A5))), 1)) * ROW(INDIRECT("1:"&LEN(A5))), 0), ROW(INDIRECT("1:"&LEN(A5))))+1, 1) * 10^ROW(INDIRECT("1:"&LEN(A5)))/10), and then drag the fill handle to fill the range you need to apply this formula. See screenshot:

Notes:

1. A5 stands the first data you want to extract numbers only from the list.

2. The result will be showed as 0 when there are no numbers in the string.

Extract numbers only from text strings:

With Kutools for Excel’s EXTRACTNUMBERS function, you can quickly extract only numbers from the text string cells. Click to download Kutools for Excel!

Method 2: Extract number only from text strings with VBA code

Here is a VBA code which also can do you a favor, please do as follows:

1. Hold down the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Extract number only from text string:

Sub ExtrNumbersFromRange()
Dim xRg As Range
Dim xDRg As Range
Dim xRRg As Range
Dim nCellLength As Integer
Dim xNumber As Integer
Dim strNumber As String
Dim xTitleId As String
Dim xI As Integer
xTitleId = "KutoolsforExcel"
Set xDRg = Application.InputBox("Please select text strings:", xTitleId, "", Type:=8)
If TypeName(xDRg) = "Nothing" Then Exit Sub
Set xRRg = Application.InputBox("Please select output cell:", xTitleId, "", Type:=8)
If TypeName(xRRg) = "Nothing" Then Exit Sub
xI = 0
strNumber = ""
For Each xRg In xDRg
xI = xI + 1
nCellLength = Len(xRg)
For xNumber = 1 To nCellLength
If IsNumeric(Mid(xRg, xNumber, 1)) Then
strNumber = strNumber & Mid(xRg, xNumber, 1)
End If
Next xNumber
xRRg.Item(xI) = strNumber
strNumber = ""
Next xRg
End Sub

3. And then, press F5 key to run this code, and a prompt box is popped out to remind selecting the text range you want to use, see screenshot:

4. Then, click OK, another prompt box is following, please select a cell to output the result, see screenshot:

5. At last, click OK button, and all numbers in the selected cells have been extracted at once.

Method 3: Extract number only from text string with Kutools for Excel

Kutools for Excel also has a powerful function which is called EXTRACTNUMBERS, with this function, you can quickly extract only the numbers from the original text strings.

Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.

After installing Kutools for Excel, please do as follows:

1. Click a cell besides your text string where you will put the result, see screenshot:

2. Then click Kutools > Kutools functions > Text > EXTRACTNUMBERS, see screenshot:

3. In the Function Arguments dialog, select a cell which you want to extract the numbers from the Txt text box, and then enter true or false into the N text box, see screenshot:

Note: the argument N is an optional item, if you enter true, it will return the numbers as numerical, if you enter false, it will return the numbers as text format, the default is false, so you can leave it blank.

4. And then click OK, the numbers have been extracted from the selected cell, then drag the fill handle down to the cells you want to apply this function, you will get the following result:

Method 4: Extract decimal number only from text string with formula

If the text strings which including some decimal numbers in your worksheet, how could you extract only the decimal numbers from the text strings?

The below formula can help you to extract the decimal numbers from the text strings quickly and easily.

Enter this formula：=LOOKUP(9.9E+307,--LEFT(MID(A5,MIN(FIND({1,2,3,4,5,6,7,8,9,0}, $A5&"1023456789")),999),ROW(INDIRECT("1:999"))))，and then fill handle down to the cells that you want to contain this formula, all the decimal numbers have been extracted from the text strings, see screenshot:

Extract number only from strings with Kutools for Excel

Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Download and free trial Now!

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...

Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...

Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...

Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...

Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...

Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...

Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...

More than 300 powerful features. Supports Office/Excel
2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features
30-day free trial. 60-day money back guarantee.

Hello, how can i extract the cheque no.only from the below text

OUTWARD CLEARING CLRG CHQ DEPOSIT CHQ. NO: 000123~700320456 ABCD ARAB PLAZ BRANC Value DATE, 01/02/2020 - S79519642

i tried below formula and its working but i need to change the 1:57 by calculating how many character before the first digit plus how many digits i want to extract.
=MIN(FIND({0,1,2,3,4,5,6,7,8,9},A3&"0123456789"))+5 im using this formula to know how many characters before the first number..

Hi. I wonder to know is it possible to extract from the next string '102-105+106-10605-10605 -10631-10632-10633-10634-10635+107' all values of only three digits that have sign '-' (i.e. minus) before them (or plus - doesn't matter). Then extract extract all 5-digits values with the same rule? If this is possible to do I will save many many hours of manual work that I can devote to lot's of uselful tasks.

P.S.
I know that regular expressions are able to do that, BUT... I hate their syntax, so I'm searching any other method to complete this task.

Hi, is it possible to extract the numbers before "g", for example : 25,20,15,25,300,40

Ali Baba Dark Chocolate 25g box 12 pcs
Ali Baba Dark Chocolate 20g*24 box
Cadbury 5 Star White Chocolate 15g
Kinder 2 White Chocolate 25g*24 ALpella Biscuits W/Marshmallow300g
Alpella Chocolate 40g

did anyone answer or did you figure this out? this is exactly my problem right - even down to the letter 'g'. the problem with the formula I am using now is that it returns the first number, if there are more than one, from the string and not the number I am wishing to return.

Hi, is it possible to extract the numbers before "g", for example : 25,20,15,25,300,40

Ali Baba Dark Chocolate 25g box 12 pcs
Ali Baba Dark Chocolate 20g*24 box
Cadbury 5 Star White Chocolate 15g
Kinder 2 White Chocolate 25g*24
ALpella Biscuits W/Marshmallow300g
Alpella Chocolate 40g

Hi ! You guys are impressive with formulas... I need one to extract the room number of a conference room. The Source Cells looks like AB ABCD CITY-Street-1-004-REST/Pers1 ABCD AB. I need to extract the 004 from it. The city lenght varies, as well as the street name as well as the floor number (this one is 1 but it could be 12). I was trying to find a way to jump to third "-" and take only the follow digits and stop at next alphabetical characters. I don't want to take the numbers of persons the room can have (Pers1)...

Hello, I could use help with a formula. I have read through these posts thinking I could find a formula or two that I could pull from to make work but I can't get it just right. I have product descriptions where the last section represents the case count (i.e CS/6 means 6 in a case). I would like a formula to pull out just the case count number. Here are a couple examples: LUCR LACT FR 1 % CALC CHOC 64 OZ CS/6 (need 6 pulled out), PCHP DAIRY CRMR FR VAN 32 OZ CS/12 (need 12 pulled out), and GLEN HALFNHALF ASEP SS GU 3/8 OZ CS/360 (need 360 pulled out).

Hi, Satya,
To extract only the state code number, you should apply the below formula:
=MID(TRIM(A1),FIND(CHAR(1),SUBSTITUTE(TRIM(A1)," ",CHAR(1),LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))))+1,5)
If you want to extract all numbers in the last, please use this formula:
=MID(TRIM(A1),FIND(CHAR(1),SUBSTITUTE(TRIM(A1)," ",CHAR(1),LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))))+1,10)

Hello, Shahid,
To extract the decimal numbers from text strings, the below article may help you, please try.
https://www.extendoffice.com/documents/excel/3271-excel-extract-decimal-number-from-string.html

hi.if i have a list which has text and Control numbers and phone number all in one cell but each record has different positions for the 3, and i want to extract control numbers(which all begin with say value 44133*****) how best can i extract that information

" Hotel to kadamtali: 20/(r).kadamtali to charkhai bazar:90/.(cng).bazar to site:20/(r).site to charkhai bazar:20/.charkhai bazar to sharker bazar:80/.(cng) kanaigath to site:30/(r).site to kanaigath:50/(r).carry matarials).sharkerbazar to syleth : 870/.(cng Reserve,carry one site matarials).kadamtali to zindabazar:40/.zindbazar to amborkhana:20/.amborkhana to companygonj:200/.(cng).companygonj to vholagonj site:30/.vholagonj site to amborkhana:2 seat,400/cng.(carry matarials),amborkhana to upashar:60/(cng).carry matarials.

Here i want to take the value ( "/") before this. and add them.

"Select a blank cell that is adjacent to the list you want to extract number only, and type this formula =SUMPRODUCT(MID(0&A2,LARGE(INDEX(ISNUMBER(--MID(A2,ROW($1:$25),1))* ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10) (A2 stands the first data you want to extract numbers only from the list), then press Shift + Ctrl + Enter buttons, and drag the fill handle to fill the range you need to apply this formula"

It's not necessary to press Shift + Ctrl + Enter. Press only ENTER (sumproduct know to work with array)

If you just need to extract the number codes from the addresses, may be the Kutools for Excel's Extractnumbers function can help you.
Please view the screenshot image:

Hi, I would like to know if there is a formula to get the total $ value of this string in Excel (Guy1-$201.6, Guy2-$915.85, Guy3-$495, Guy4-$1211, Guy5-$492) - and extent to 20 'Guys'. I don't want to convert etc ... I want a formula please. Thanks

Good day I would like to extract the first set of numbers from a list. ie (122,90,84,118.4,128.9) Any ideas on what formula I can use? COIL112X2.5 COIL90X2.5 COIL84X2.0 COIL118.4X1.8 COIL128.9X2.0

I have a huge list of Barcodes with product description which might have weights and other numeric values. I wish to extract only the barcodes which are 8-13 digits in len. Is there any way the above mentioned formulae can be tweeked.

only one problem - it won't work with the decimals. example, if A1 is 2.25LXX, it will extract it as 225, not 2.25, is there a way in your formula to extract the decimal number also? thanks in advance!

have been trolling the web for answer to simply extra numbers from string in excel and after many overbearing, confusing formulas yours worked like a treat!!