格式点或逗号取决于位置
我正在使用VBA-excel将csv文件导入到excel中。 我坚持在VBA格式。 如果我的区域设置为美国默认,它工作正常。 但是,如果任何区域使用逗号作为小数,它不能正常工作了。
fuction formatPercentValue (value as string) as string //value = 1 formatPercentValue = formatPercent(Round(CDbl(Val(value)), 5), 6) // US: 100.000000%, HU (Hungary): 100,000000%
当我打电话的时候
r as range r.value = formatPercentValue (value) // US: r.value = 1, HU: r.value = 1000000
我不知道如何解决,因为当它出现在excel US: 100%
HU: 100000000%
。 我不知道为什么r.value在美国可以设置1
,但不在HU。
您应该使用Application.International
来testing设置并应用不同的格式:
If Application.International(xlCountrySetting) <> 1 Then If Application.International(xlDecimalSeparator) <> "." Then