delete non-numeric characters in a string

novice_2010

Board Regular
Joined
Mar 18, 2010
Messages
105
Hello, All

Suppose cell A1 is "~1&2_a3^4d", I want to delete those non-numeric characters so that cell A1 becomes "1234". Is thee a way to do it? Thanks.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Good morning Novice (I'm a novice too)

There are several methods for reaching just numeric charachters in a cell
find, replace, substitute etc most numbers do not come as complicated as the one you have posted and I would say if you had only a few like that then just type out the numbers as you have.
 
Upvote 0
novice_2010,


Excel Workbook
AB
1~1&2_a3^4d1234
2
Sheet1




The array formula in cell B1 confirmed with CTRL + SHIFT + ENTER (not just ENTER):

=SUM(MID(0&A1,LARGE(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))* ROW(INDIRECT("1:"&LEN(A1))),ROW(INDIRECT("1:"&LEN(A1))))+1,1)*10^ROW(INDIRECT("1:"&LEN(A1)))/10)
 
Upvote 0
Thank you very much, hiker95. That is really a very complicated formula. I may need some time to digest :--)

Dryver14, thanks for your suggestion. I can do it manually; but when data set is big, manually editing every single cell is really boring and tiring :--)
 
Upvote 0
Novice,

I only suggested doing it maunally if there were a few the point I was trying to make is that Hikers solution is brilliant but if your set of values just contained something like 6 * - you could just use find and replace.
 
Upvote 0
You might try this UDF:
Code:
'http://www.mrexcel.com/forum/showthread.php?t=362461
Function TextNum(ByVal txt As String, ByVal ref As Boolean) As String
With CreateObject("VBScript.RegExp")
    .Pattern = IIf(ref = True, "\d+", "\D+")
    .Global = True
    TextNum = .Replace(txt, "")
End With
End Function
'=TextNum(A1,1)
'1 for Text only, 0 for Numbers only
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,571
Members
452,927
Latest member
whitfieldcraig

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