Changing point to comma in numbers, macro gives another result compared to manually changing

RobbertN

New Member
Joined
Dec 27, 2014
Messages
5
Hello,

I'm importing data containing numbers in a single row into excel from another source.
The numbers are written with a point (.) as a decimal sign (for example; 1.20 , 231.1, 9.0)
Every cell contains only one number though.
I'm located in The Netherlands, so I have to convert those numbers, so the point is replaced by a comma-sign.

I've found a way to do this, by selecting the numbers, changing the cell type to text, using the replace function to search for every point and to replace it by a comma. After this, I change the cell type to number.

This solves the full problem, so I thought I would record this into a macro.
I recorded the macro, and used the same procedure.
After this, I pasted the same dataset into excel, and executed the macro.
Unfortunately, this resulted in numbers formatted as text. (indicated with the familliar green little triangle)

To me, it seems the same procedure on the same data gives different results if executed with a macro instead of manually... How can I solve this?
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
you change your excel settings directly from VBA (don't remember where they're located if you wish to do it manually but they're somewhere) and not having to worry about it anymore

Code:
Sub chg()
    Application.DecimalSeparator = ","
    Application.ThousandsSeparator = "."
End Sub
 
Upvote 0
yes, it will use a . as decimal separator and a , for thousands

you must also include this line of code

Code:
Application.UseSystemSeparators = False
 
Upvote 0
I'm sorry, but that is not really an option here... Partly because i'm used to using comma's, and because the data must be reported with comma's after the calculations in Excel...
 
Upvote 0
ok, select your numbers and try then

Code:
Sub ChangeCommas()
    Selection.Replace ".", ",", xlPart, xlByRows, False
End Sub
 
Upvote 0
Thanks for the reply, this does change the points into comma's, but the numbers are formatted as text... This is the main problem I wrote about in the opening post. The result is excel won't carry out calculations with "text stored numbers"...

(image)
 
Last edited:
Upvote 0
ok one more try:

Code:
Sub ChangeCommas()
    Selection.Value = Application.Transpose(Evaluate(Replace("Transpose(SUBSTITUTE(@,"","","".""))", "@", Selection.Address)))
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top