Extract Only Numbers From Text String

mgirvin

Well-known Member
Joined
Dec 15, 2005
Messages
1,247
Office Version
  1. 365
Platform
  1. Windows
Dear Smartest Excelers Around,

Is there a one cell formula that could take this string in cell A1:

45t*&65/

and extract only the numbers and deliver this

4565

to a single cell?

The formula would have to be able to deal with all 255 ASCII characters and be copied down a column.
 
ok - I just try #37 and was able to make it work. Probably input error that it did not work the first time. Thank you for the suggestion.
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
The only problem with that Formula in #37 is it will return a number, so any leading zero will be by pass
 
Upvote 0
Hi, i got a question here regarding for extracting the only number. But how about fraction? I would like to extract this.

[TABLE="width: 247"]
<colgroup><col width="247"></colgroup><tbody>[TR]
[TD="width: 247"]E.g. Flamengo (2/13) to only 2/13

Any idea?
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi, i got a question here regarding for extracting the only number. But how about fraction? I would like to extract this.

[TABLE="width: 247"]
<tbody>[TR]
[TD="width: 247"]E.g. Flamengo (2/13) to only 2/13

Any idea? [/TD]
[/TR]
</tbody>[/TABLE]
Unfortunately one example is usually not enough to decide on a course of action...

Is the number always at the end of the text as shown in your example? If not, can other numbers (digits) be located after it?

Is the number always surrounded by parentheses? If so, will those parentheses always be the only parentheses in the text?

Can there be any other numbers (digits) located before the number you want?
 
Upvote 0
Hi, i got a question here regarding for extracting the only number. But how about fraction? I would like to extract this.

[TABLE="width: 247"]
<tbody>[TR]
[TD="width: 247"]E.g. Flamengo (2/13) to only 2/13

Any idea?[/TD]
[/TR]
</tbody>[/TABLE]


use this UDF

Code:
Function RemoveApha(cellInput) As String           
    Set cellInput = Intersect(cellInput.Parent.UsedRange, cellInput)
    
    For i = 1 To Len(cellInput)
        Select Case Mid(cellInput, i, 1)
            Case 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, " ", "-", "/"
                Charval = Mid(cellInput, i, 1)
            Case Else
                Charval = ""
        End Select
    RemoveApha = RemoveApha & Charval
    Next i
        
End Function
 
Upvote 0
Try your UDF with this text "a1b2c3d(2/3)e4" and you will see why I asked the questions that I did in Message #44.


Hi Rick,

i used the UDF and i got [TABLE="width: 64"]
<tbody>[TR]
[TD]1232/34[/TD]
[/TR]
</tbody>[/TABLE]

i thought the oddchecker is looking for to remove all normal alpha char and then retain numbers and that special chars.

or perhaps i misunderstood.
 
Upvote 0
Hi Rick,

i used the UDF and i got [TABLE="width: 64"]
<tbody>[TR]
[TD]1232/34[/TD]
[/TR]
</tbody>[/TABLE]

i thought the oddchecker is looking for to remove all normal alpha char and then retain numbers and that special chars.

or perhaps i misunderstood.
I got the impression he was looking for a specific number. Because of our different interpretations is why I said "Unfortunately one example is usually not enough to decide on a course of action..." The question comes up, though... if the OP really wanted numbers only, then why keep the slash? What about decimal points, thousands separators, plus minus signs, currency symbols, etc. Hopefully the OP will be along shortly to clarify what his question actually is.
 
Upvote 0

Forum statistics

Threads
1,224,869
Messages
6,181,485
Members
453,046
Latest member
Excelvbaexpert

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top