Note: The other languages of the website are Google-translated. Back to English

How to extract number only from text string 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:

doc extract numbers only 2

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!

doc extract numbers only 14


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:

doc extract numbers only 3

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

doc extract numbers only 4

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:

doc extract numbers only 5

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

doc extract numbers only 6

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:

doc extract numbers only 7

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:

doc extract numbers only 8

Click to Download and free trial Kutools for Excel Now!


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:

doc extract numbers only 13


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!

Relative Articles:


The Best Office Productivity Tools

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...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • 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.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (61)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Who can explain this formula to me .
This comment was minimized by the moderator on the site
Christ it was either Multiplan or Quattro Pro that used to return the string value of a single item with a single command...
This comment was minimized by the moderator on the site
This formula fails with decimal places. e.g. "1.5 grams of abc" returns "15".
This comment was minimized by the moderator on the site
Great formula...very helpful! But, could you please advise what can I do with chinese characters? I guess it considers them as figures. Any idea?
This comment was minimized by the moderator on the site
Thank you thank you! 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!! much appreciated :D
This comment was minimized by the moderator on the site
this formula =SUMPRODUCT(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1,ROW($1:$25),1))* ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10) worked great, for any number under 4 digital but I have numbers over 1000 that I need to extract - any advice?? thanks :)
This comment was minimized by the moderator on the site
@jb: Use this UDF: Function ExtractNumber(cell As Range) As Long Dim Num As String For i = 1 To Len(cell) If IsNumeric(Mid(cell.Value, i, 1)) Then Num = Num & Mid(cell.Value, i, 1) Next i ExtractNumber = Num End Function
This comment was minimized by the moderator on the site
How about this... :-) =NPV(-0.9,IFERROR(MID(A1,1+LEN(A1)-ROW($1:$999),1)/10,"")) Press Ctrl + Shift + Enter
This comment was minimized by the moderator on the site
This will more short.. =NPV(-0.9,IFERROR(MID(A1,100-ROW($1:$99),1)/10,"")) with CSE
This comment was minimized by the moderator on the site
Great! this works Deepak! 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!
This comment was minimized by the moderator on the site
I think that this formula will be easier =SUM(IFERROR(VALUE(MID(A1;ROW($1:$100);1));0))
This comment was minimized by the moderator on the site
[quote]I think that this formula will be easier =SUM(IFERROR(VALUE(MID(A1;ROW($1:$100);1));0))By mohamed elrify[/quote] What u have posted will some then not extract them!!
This comment was minimized by the moderator on the site
perfect, just have wasted a day in the factory by the scanning machine in 38' centigrade standing with no results, but this blew it up. super thanks
This comment was minimized by the moderator on the site
I want the Formula that contains number but stop working where next alphabet is start. Like: hh123456f2 gh123f3 ff1234g1 I don't want last numerical number after the alphabet. Hope you understand what I'm trying
This comment was minimized by the moderator on the site
thanks, really helpful
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Try the formula =+MID(C13,5,FIND("X",C13)-1-LEN("coil"))
This comment was minimized by the moderator on the site
=+MID(C14,5,FIND("X",C14)-1-LEN("coil"))
This comment was minimized by the moderator on the site
Updated Formula which handles decimal point and works on any number length =SUMPRODUCT(MID(0&D2,LARGE(INDEX(ISNUMBER(--MID(D2,ROW(INDIRECT("$1:$"&LEN(D2))),1))* ROW(INDIRECT("$1:$"&LEN(D2))),0),ROW(INDIRECT("$1:$"&LEN(D2))))+1,1)*10^ROW(INDIRECT("$1:$"&LEN(D2)))/POWER(10, IFERROR(LEN(D2)-FIND(".", D2)-1, 1))) D2 is the cell where you have number in a string format Copy this formula to E2 and press CTRL+SHIFT+ENTER
This comment was minimized by the moderator on the site
hi man can you explain how the formula works?
This comment was minimized by the moderator on the site
it doesnt work on below scenario:

Provident<space>Fund<2spaces>-5.55556%<space>0.00<space>

Same like this : Provident Fund -5.55556% 0.00
i want -5.55556% or -0.055556
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Try the formula =MID(F14,FIND("$",F14),100)+0
This comment was minimized by the moderator on the site
How do i get True or false when i compare numbers & text for example
d1, d2, d3 3 TRUE


d1, d2, d4, d5 5 FALSE
This comment was minimized by the moderator on the site
I want to extract pincodes from this list:

Adikavi Nannaya University, Jaya Krishnapuram, Rajahmundry – 533 105, Andhra Pradesh.
Andhra University, Visakhapatnam-530 003.
Acharya Nagarjuna University, Nagarjuna Nagar, Guntur-522 510.
Dravidian University, Kuppam-517 425.

Is there anyone can help me on this?
This comment was minimized by the moderator on the site
Hello, Rashmita,

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:
This comment was minimized by the moderator on the site
Hi,
i want to extract only the number after the Colon in a cell
80lb : 12
90lb : 4
110lb : 0
120lb : 20
130lb : 6
This comment was minimized by the moderator on the site
Hello, andrew,
To extract the numbers after the colon,pleas apply the below formula:
=MID(A1,FIND(":",A1)+2,256)
Please try it, thank you!
This comment was minimized by the moderator on the site
Hi

I want to extract only number of below example:

'-2500'
This comment was minimized by the moderator on the site
Hi, Teng, all of the methods provided in current article can help you, just try.
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations