Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cel As Range
Set rng = Intersect(Target, [A1:G25])
If Not rng Is Nothing Then
Application.EnableEvents = False
For Each cel In rng
If cel <> "" Then
cel = Replace(cel, ".", "")
cel = Replace(cel, ",", ".")
cel.Formula = "=" & cel & "/1000"
End If
Next
Application.EnableEvents = True
End If
End Sub
I got a debug error because of the comma again, e.g. 500,25 will give the error. Any number with a comma will give an error.Try this :
Code:Private Sub Worksheet_Change(ByVal Target As Range) Dim rng As Range, cel As Range Set rng = Intersect(Target, [A1:G25]) If Not rng Is Nothing Then Application.EnableEvents = False For Each cel In rng If cel <> "" Then cel = Replace(cel, ".", "") cel = Replace(cel, ",", ".") cel.Formula = "=" & cel & "/1000" End If Next Application.EnableEvents = True End If End Sub
I got a debug error because of the comma again, e.g. 500,25 will give the error. Any number with a comma will give an error.