Format a cell as arbitrary currency regardless of locale, using VBA

 ̄綄美尐妖づ 提交于 2019-12-01 06:59:30

I just recorded a macro to set the format to $xx.xx and it created this: [$$-409]#,##0.00. Looks like the -409 localises the currency to a particular country; it works without it - try changing yours to .NumberFormat = "[$" & sym & "]#,##0.00"

Btw guess I read your question somewhat after posting ;) Excel is well influenced by the regional settings of your computer for currency, language, dates... Using numberformat can force it to keep the sign you require. if it is a matter of rounding up you can try to: On Excel 2010, go to File - Options - Advanced and scroll down to "When calculating this workbook" and click on the "set precision as displayed" and OK out. 

Try this: given your values are numerics/ integers/decimals....

Range("a2").Style = "Currency"

Or you can use format:

Format(value, "Currency")

Format(Range(a2).value, "Currency")

References:

http://www.mrexcel.com/forum/excel-questions/439331-displaying-currency-based-regional-settings.html

http://www.addictivetips.com/microsoft-office/excel-2010-currency-values/

(PS: I am on mobile, you may try these two links)

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