I want to change decimal separator from comma to point. How can I do this with macro?
-
I don't think you can do this with macro. Decimal separator is specified in Windows regional settings. You can, of course, change all commas to points in your file, but if you don't change Windows regional settings this will just make your values invalid as numbers for Excel.Taosique– Taosique2014-01-21 08:18:11 +00:00Commented Jan 21, 2014 at 8:18
-
You made me sad bro :(user3215646– user32156462014-01-21 08:21:31 +00:00Commented Jan 21, 2014 at 8:21
3 Answers
Actually you can do it.
Sub Macro1()
With Application
.DecimalSeparator = "."
.ThousandsSeparator = ","
.UseSystemSeparators = false
End With
End Sub
Importante Note:
This change will take effect only inside Excel and on ALL Excell files open. And the next time you open Excel, this settings will be active.
You could record the state of this settings before changing them so that you can return the application to its original state.
1 Comment
You can't.
The decimal separator is a part of your operating system's regional settings.
It cannot be changed on an application (Excel) level or a file (Excel workbook) level.
If you have problems with the decimal separator in a file that you want to use in Excel, please edit your question to state the real issue.
Your system may use the . as a decimal, but the file you want to import uses a comma. Open the file in a text editor and replace commas with dots and dots with commas.
- for example: replace all commas with # (or another character that is highly unlikely to appear anywhere in the file)
- then replace all dots with commas
- then replace all # with dots.
Save the file and then import into Excel.
4 Comments
comma as separator although ? Application.DecimalSeparator returns dot. Do you speak about that?