View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Remove Non-Numerics from String

Hi ExcelMonkey,

Try:

'=============
Public Sub TestIt()
Const aStr As String = "Aa$1Bb2$Cc3d$Dd4$"
MsgBox NoUcasePlus(aStr)
End Sub

'-----------------
Public Function NoUcasePlus(sStr As String) As Variant
Dim oRegExp As Object

Set oRegExp = CreateObject("VBScript.RegExp")

With oRegExp
.IgnoreCase = False
.Global = True
oRegExp.Pattern = "[A-Z$]"
NoUcasePlus = .Replace(sStr, vbNullString)
End With
End Function
'<<=============


---
Regards,
Norman


"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