Excel Print number with correct decimal Seperator

2019-07-27 22:07发布

I use the print function to export a Cell Value to csv file. I use this macro on several PCs with different Localization Settings. The problem i am experiencing is, that on some PCs the Output is 4,11 and 4.11 on others. Is there any Format Method, that allows me always write a Number with a semicolon as decimal Seperator?

1条回答
Deceive 欺骗
2楼-- · 2019-07-27 22:10

As far as I'm aware, there is no format method for changing the decimal separator. Instead your options are temporarily telling Excel to use a special character or using Replace().

Application.UseSystemSeparators = False
Application.DecimalSeparator = ";"
Print #1, rngValue.Text

Or

Print #1, Replace(rngValue, ",", ";") 

In either case you then have a problem, when reading the numbers back in, of converting them back to the correct character so they are considered numbers.

A better question might be how do programmers in places that use the comma as the decimal separator handle decimal values in CSV files?

查看更多
登录 后发表回答