Hello, guys!
I'm trying to covert a column full of numbers like 1234,56 or 987.654 to this format 1234.56, max 2 decimals and "." instead of ",". But when I try to find the "," the method completely ignores it...
I tried to change the format from General to Numbers, Text etc., but no success
The code is not very good yet, first I'm trying to solve this problem. My code look likes this:
(Thanks in advance)
For Each cell In campoCol.Rows
c = cell.Value
d = InStr(1, c, ".", vbTextCompare) ' FIND DECIMAL POINT
If d > 0 And Len(c) > (d + 2) Then ' MORE THAN 2 DECIMAL NUMBERS
MsgBox ("2 decimals only")
End If
Set valorVirgula = Selection.Find(What:=",", SearchOrder:=xlByRows)
If Not valorVirgula Is Nothing Then
Do
valorVirgula.Replace What:=",", Replacement:=".", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Set valorVirgula = Selection.FindNext(valorVirgula)
Loop While Not valorVirgula Is Nothing
End If
I'm trying to covert a column full of numbers like 1234,56 or 987.654 to this format 1234.56, max 2 decimals and "." instead of ",". But when I try to find the "," the method completely ignores it...
I tried to change the format from General to Numbers, Text etc., but no success
The code is not very good yet, first I'm trying to solve this problem. My code look likes this:
(Thanks in advance)
For Each cell In campoCol.Rows
c = cell.Value
d = InStr(1, c, ".", vbTextCompare) ' FIND DECIMAL POINT
If d > 0 And Len(c) > (d + 2) Then ' MORE THAN 2 DECIMAL NUMBERS
MsgBox ("2 decimals only")
End If
Set valorVirgula = Selection.Find(What:=",", SearchOrder:=xlByRows)
If Not valorVirgula Is Nothing Then
Do
valorVirgula.Replace What:=",", Replacement:=".", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
Set valorVirgula = Selection.FindNext(valorVirgula)
Loop While Not valorVirgula Is Nothing
End If