Skip to main content

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:

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


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!
Comments (61)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
how to get a extract extact numbers from text
This comment was minimized by the moderator on the site
Hi, I'm looking to list all numbers in a string before a certain character. The string has letters and numbers, so I want to remove the letters and only list the numbers that appear before the second minus sign "-". Example:MUMUT-S941-22460991e002
I want that to isolate the numbers 941 in the above example.
This comment was minimized by the moderator on the site
How to use Index instead of Indirect to extract number from string. Indirect is volatile and Index can replace it as per http://www.excelhero.com/blog/2011/03/the-imposing-index.html. Thanks Ahead!
This comment was minimized by the moderator on the site
Hello! I found the following formula to extract only the numbers from text strings in Excel very useful

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)

Could you explain more on this formula as it seems quite complicated? Many thanks.
This comment was minimized by the moderator on the site
Reading ID: 3151346 BeatO User ID: 239930 Name: Mahesh Phone: 9823010759 Email: City: nashik State: Maharashtra Reading: 55 Meal Time: Random Meal Type: RANDOM Reading Time: 2020-03-01 00:15:57 View user readings in Portal



I want to extract numeric no. post Reading text
This comment was minimized by the moderator on the site
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..

=TEXTJOIN("",TRUE,IFERROR(MID(A3,ROW(INDIRECT("1:57")),1)+0,""))
This comment was minimized by the moderator on the site
=Mid(A2,find("CHQ. NO", A2)+9,6)
This comment was minimized by the moderator on the site
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.

Thanks in advance.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
can any one answer this question, how to extract the no's
This comment was minimized by the moderator on the site
You may try select the number before g in the first cell, copy and paste it in new cell. Then press CTRL + E. All the number before g will be auto generated. 

This comment was minimized by the moderator on the site
Tkssssss you saved my day :) God bless you
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations