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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

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
 

Watch MrExcel Video

Forum statistics

Threads
1,130,112
Messages
5,640,174
Members
417,130
Latest member
Darion2021

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