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 change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Dryver14

Well-known Member
Joined
Mar 22, 2010
Messages
2,396
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.
 

hiker95

Well-known Member
Joined
Apr 8, 2009
Messages
17,649
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)
 

novice_2010

Board Regular
Joined
Mar 18, 2010
Messages
105
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 :--)
 

Dryver14

Well-known Member
Joined
Mar 22, 2010
Messages
2,396
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.
 

Armando Montes

Well-known Member
Joined
Sep 2, 2008
Messages
505
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,748
Messages
5,855,439
Members
431,732
Latest member
albertdi827

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
Top