Extracting Only Numeric Characters from Cells

wren17

Board Regular
Joined
May 25, 2002
Messages
52
Hello Everyone:

I am looking for a formula or Macro that will extract Only the numeric characters from a cell.
Example: I have a cell with "TM310".
I want a formula that will extract only the 310 and exclude the TM.

Now I am well aware of left,right, and mid formulas, but what makes this difficult is that I have thousands of cells and the models change. sometimes it looks like "TM310V" or "S123-VC", so it makes hard coding a set value like right(A1,3) not at all usefull.

Any assistance would be greatly apprecatiated

thanks,
Wren
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Here's another function. The only reason I add it is due to performance implications, although both are quick:<font face=Courier New><SPAN style="color:darkblue">Function</SPAN> CombNums(myStr<SPAN style="color:darkblue">As</SPAN><SPAN style="color:darkblue">String</SPAN>)<SPAN style="color:darkblue">As</SPAN><SPAN style="color:darkblue">Long</SPAN><SPAN style="color:darkblue">Dim</SPAN> b()<SPAN style="color:darkblue">As</SPAN><SPAN style="color:darkblue">Byte</SPAN>, z<SPAN style="color:darkblue">As</SPAN><SPAN style="color:darkblue">Long</SPAN>, i<SPAN style="color:darkblue">As</SPAN><SPAN style="color:darkblue">Integer</SPAN>
b = myStr<SPAN style="color:darkblue">For</SPAN> i =<SPAN style="color:darkblue">LBound</SPAN>(b)<SPAN style="color:darkblue">To</SPAN><SPAN style="color:darkblue">UBound</SPAN>(b)<SPAN style="color:darkblue">Step</SPAN> 2
    <SPAN style="color:darkblue">If</SPAN> ChrW$(b(i))<SPAN style="color:darkblue">Like</SPAN> "#"<SPAN style="color:darkblue">Then</SPAN> z = z & ChrW$(b(i))<SPAN style="color:darkblue">Next</SPAN>
Erase b
CombNums = z
z =<SPAN style="color:darkblue">Empty</SPAN><SPAN style="color:darkblue">End</SPAN><SPAN style="color:darkblue">Function</SPAN></FONT>

Here's some examples of it's use:
Book1
ABCD
1sdfh34-4sjdfk3TM310VorS123-VCTM310VS123-VC
23443310123310123
3234
Sheet3


If you have a lot of these, you'll want to reduce your lead-time as muchh as possible. This underwent limited testing. Have a nice day.
 
Upvote 0
Try...

=--MCONCAT(IF(ISNUMBER(SETV(MID(A1,INTVECTOR(LEN(A1),1,,1),1))+0),GETV(),""))

which needs to be array-entered, that is, using control+shift+enter.

This formula requires the morefunc add-in.
Book5
ABCD
1TM310310
2TM310V310
3S123-VC123
4
5
Sheet1


If you prefer, you can use the following whic does not require morefunc...

=--ACONCAT(IF(ISNUMBER(V(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))+0),V(),""))

Also array-entered. ACONCAT and V are UDFs in VBA, whose codes are available on this site.
 
Upvote 0
Aladin, I can't find udf = v via the search. I found aconcat...

In any case, I would like to replicate the aconcat solution, would you mind providing the code for v or a pointer?

Thanks in advance,
Nathan
 
Upvote 0
NateO said:
Aladin, I can't find udf = v via the search. I found aconcat...

In any case, I would like to replicate the aconcat solution, would you mind providing the code for v or a pointer?

Thanks in advance,
Nathan

Public Function V(Optional vrnt As Variant) As Variant
'
' Stephen Dunn
' 2002-09-12
'
Static vrntV As Variant
If Not IsMissing(vrnt) Then vrntV = vrnt
V = vrntV
End Function
 
Upvote 0

Forum statistics

Threads
1,215,329
Messages
6,124,302
Members
449,149
Latest member
mwdbActuary

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