View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Remove Non-Numerics from String

Not sure if you can improve much on something simple like this:

Sub ReplaceUpperAndDollar(strString As String, Optional strReplace As
String)

Dim i As Long
Dim strFind As String

strFind = "ABCDEFGHIJKLMNOPQRSTUVWXYZ$"

For i = 1 To Len(strFind)
strString = Replace(strString, Mid$(strFind, i, 1), strReplace, 1, -1,
vbBinaryCompare)
Next

End Sub


I would only bother with something more complex if speed really is
important.

RBS


"ExcelMonkey" wrote in message
...
I need a function to remove "$" and all capitalized letters (i.e. A, B,
etc)
from a string variable. Assuming that regular expressions is the way to
to
using the Replace method. Any ideas on how to do this via VBA?

Thanks

EM