1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
Sub conv()
Dim I, J, K, L, M, X
Dim V As Boolean, P As Boolean, S As Boolean
Dim T As String
T = ("123 123 256 789,456789")
K = Split(T, ".")
J = Split(K(UBound(K)), ",")
I = 10 ^ Len(J(UBound(J)))
M = Replace(T, ",", "")
M = Replace(M, ".", "")
M = Replace(M, " ", "")
L = 1
If Len(M) <= Len(CStr(I)) Then L = J(UBound(J)) / I
If InStr(T, ",") Then V = True
If InStr(T, ".") Then P = True
If InStr(T, " ") Then S = True
If (V And P) Or (V And S) Or (P And S) Then
X = CDbl(M) / L
Else
X = CDbl(M)
End If
Debug.Print X
End Sub |