使用宏格式将Excel格式化为小数位 [英] Format cells in excel for decimal places using a macro
本文介绍了使用宏格式将Excel格式化为小数位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何格式化单元格(D :) 2小数位数单元格(E :) 1小数位和单元格(H:)小数点在Excel中使用宏?
How can I format Cell (D:) 2 decimals places Cell (E:) 1 decimal place and Cell (H:)3 decimals places in excel using a macro?
推荐答案
范围的数字格式属性将格式化为任何自定义格式
the numberformat property of a range will format it to any custom format
sheets("sheet1").range("D:D").numberformat = "0.00"
sheets("sheet1").range("E:E").numberformat = "0.0"
sheets("sheet1").range("H:H").numberformat = "0.000"
对于使用逗号或货币显示的数字,这将工作:
for numbers with a comma or currency displayed this would work:
sheets("sheet1").range("D:D").numberformat = "&#,##0"
这篇关于使用宏格式将Excel格式化为小数位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文