View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default removing text characters from a cell

If the OP is looking for a UDF, here is a non-Regular Expressions on he can
consider also...

Function RemoveAlpha(Rng As Range) As Variant
Dim X As Long
If Not Rng.Value Like "*#*" Then
RemoveAlpha = CVErr(xlErrValue)
Else
For X = 1 To Len(Rng.Value)
RemoveAlpha = Val(Mid(Rng.Value, X))
If RemoveAlpha < 0 Then Exit For
Next
End If
End Function

--
Rick (MVP - Excel)


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Function RemAlpha(str As String) As String
'Remove Alphas from a string
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
RemAlpha = re.Replace(str, "")
End Function

=RemAlpha(cellref)*1 the *1 produces a numeric value


Gord Dibben MS Excel MVP

On Tue, 23 Dec 2008 10:55:07 -0800, volleygods
wrote:

I need to find an easy function or macro to remove all text characters
from a
cell.
EX. Pail=19KG converts to 19