View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Move selected Text/Numbers from Col D to Col A/B

On Mon, 19 May 2008 07:22:58 -0400, Ron Rosenfeld
wrote:

Thanks Ron.

Always willing to adjust..............although Mrs. D may not agree with that<g


Gord

This isn't any faster than your RemAlpha routine (probably slower) but for
consistency with the RemDigits function:

It probably should be called: RemNonDigits, though.

================================
Function RemAlpha(str As String) As String
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
RemAlpha = re.Replace(str, "")
End Function
===============================

Or you could make it more generalized to Remove whatever is specified in the
Pattern:

==============================
Function RemSpec(str As String, sPattern As String) As String
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = sPattern
RemSpec = re.Replace(str, "")
End Function
===============================

So, for sPattern (what will be removed)

"\d" = digits
"\D" = non-digits
"[A-Za-z]" = all letters
and there are many other patterns that could be used.
--ron