I'm trying to run a macro that replaces a decimal value in a cell with a formula that refers to that number:
,
When I run the macro I'm getting "Run-time error '1004': Application-defined or object-defined error". I believe this is because I'm using the Finnish settings in my Excel where the decimal separator is a comma instead of a period. I believe the IsNumeric should make sure VBA understands the numbers as numbers even with the commas but I'm not getting an error if I replace the commas with periods. Is there any way to use the actual cell value regardless of the formatting instead of replacing the "cell.value" with the "Replace(cell.value, ",", ".")" wich to me seems unnecessary for VBA clearly understands the cell value as a number instead of text already.
VBA Code:
Dim cell As Range
For Each cell In Selection
If IsNumeric(cell) Then
cell.Formula = "=ROUND(" & cell.Value & "*(1+$D$5), 2)"
End If
Next cell
When I run the macro I'm getting "Run-time error '1004': Application-defined or object-defined error". I believe this is because I'm using the Finnish settings in my Excel where the decimal separator is a comma instead of a period. I believe the IsNumeric should make sure VBA understands the numbers as numbers even with the commas but I'm not getting an error if I replace the commas with periods. Is there any way to use the actual cell value regardless of the formatting instead of replacing the "cell.value" with the "Replace(cell.value, ",", ".")" wich to me seems unnecessary for VBA clearly understands the cell value as a number instead of text already.