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
Function CurSymb(Rg As Range)
L = Left(LTrim(Rg.Text), 1)
R = Right(RTrim(Rg.Text), 1)
CurSymb = IIf(Val(L), IIf(Val(R), "", R), L)
End Function
Normally you don't need an UDF to extract the numbers from the currency !
You just have to enter a formula in a cell like "=A1" and apply a standard format ...
If you really want an UDF :
Function CurVal(Rg As Range)
CurVal = Rg.Value
End Function
Application.Volatile
Function CurSymb(Rg As Range)
Application.Volatile
L = Left(LTrim(Rg.Text), 1)
R = Right(RTrim(Rg.Text), 1)
CurSymb = IIf(Val(L), IIf(Val(R), "", R), L)
End Function
Function CurVal(Rg As Range)
Application.Volatile
T = Trim(Rg.Text)
CurVal = CDbl(IIf(Val(T), T, Mid(T, 2)))
End Function
IIf(Val(L), IIf(Val(R), "", R), L)
If 1st letter is Numeric then pick Last Letter, and if Last letter is Numeric then pick 1st letter.
[pre][code]If L is a value = false then choose L
else if R is a Value = false then choose R