|
Functionの形で書くとこんなかな?
ユーザー定義関数で使っても善いし、マクロの中で使っても善いと思いますが?
Public Function NumericalValue(ByVal vntValue As Variant) As Variant
Dim i As Long
Dim lngPos As Long
NumericalValue = ""
If vntValue = "" Then
Exit Function
End If
vntValue = Left(vntValue, Len(vntValue) - 1)
lngPos = InStr(1, vntValue, ",", vbBinaryCompare)
Do Until lngPos = 0
vntValue = Left(vntValue, lngPos - 1) _
& Mid(vntValue, lngPos + 1)
lngPos = InStr(1, vntValue, ",", vbBinaryCompare)
Loop
If IsNumeric(vntValue) Then
NumericalValue = Val(vntValue)
End If
End Function
|
|