Excel Print number with correct decimal Seperator

喜欢而已 提交于 2019-12-11 07:49:51

问题


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:


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?



来源:https://stackoverflow.com/questions/8972487/excel-print-number-with-correct-decimal-seperator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!