patsdavixen
New Member
- Joined
- Mar 5, 2013
- Messages
- 32
Hi, I needed a macro that would identify the currency in a particular currency formated cell in my worksheet. I have included the code below. The problem is that since the code has "Application.Volatile" in it, everytime a cell has a formula or needs to be calculated, the following currency code runs again. I have more than 100 cells that need to be calculated in my macro and this slows it down considerably. Could some one please help me?
Thanks,
Pat
Code:
Private Function GetCurrency(ByVal r As Range) As String
Application.Volatile
Static RegX As Object
If RegX Is Nothing Then Set RegX = CreateObject("VBScript.RegExp")
With RegX
.Global = True
.Pattern = "[0-9\-\.,\s]"
GetCurrency = .Replace(r.Text, "")
End With
End Function
Thanks,
Pat