Hurricane
Sleeping Dragon
- Joined
- Dec 6, 2001
- Messages
- 1,197
Seems I´ve been getting lots of problems lately.
The case: I have an Excel file, into which I import some numerical data on a weekly basis. The imported data uses dots to mark decimals (i.e. 24.15 means 24 euros 15 cents), but I want to change this to commas which is specified in my Windows regional settings to be the decimal symbol.
This can of course be done by selecting the cells and use the edit-replace funtion, but since I do this every week, I tried to fasten things up by making it a macro instead. The problem now is that Excel won´t recognise the numbers changed by the macro as real numbers, even though they have the comma just like any other value in the sheet!
I guess this only applies to European users, but if anybody has a suggestion of how to change the macro so it would work, I would be very happy.
I use this code for the macro:
So, the problem is that if I do the exact same operation "by hand", everything works ok, but if the macro does it, Excel won´t recognise the changed values as numbers, even though they perfectly correctly contain commas.
I attach a screenshot so you can see for yourselves: note that all values have commas (cell formatting in all cells is "General"), but that the sum value only takes the values that have been corrected "by hand", i.e. the sum is 1,09 instead of 1,58.

The case: I have an Excel file, into which I import some numerical data on a weekly basis. The imported data uses dots to mark decimals (i.e. 24.15 means 24 euros 15 cents), but I want to change this to commas which is specified in my Windows regional settings to be the decimal symbol.
This can of course be done by selecting the cells and use the edit-replace funtion, but since I do this every week, I tried to fasten things up by making it a macro instead. The problem now is that Excel won´t recognise the numbers changed by the macro as real numbers, even though they have the comma just like any other value in the sheet!

I guess this only applies to European users, but if anybody has a suggestion of how to change the macro so it would work, I would be very happy.
I use this code for the macro:
Code:
Range("C34:BF34").Select
Selection.Replace What:=".", Replacement:=",", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
So, the problem is that if I do the exact same operation "by hand", everything works ok, but if the macro does it, Excel won´t recognise the changed values as numbers, even though they perfectly correctly contain commas.
I attach a screenshot so you can see for yourselves: note that all values have commas (cell formatting in all cells is "General"), but that the sum value only takes the values that have been corrected "by hand", i.e. the sum is 1,09 instead of 1,58.