office交流网--QQ交流群号

Access培训群:792054000         Excel免费交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

VBA代码设置单元格或选择区域的格式NumberFormatLocal

2020-05-22 08:00:00
zstmtony
原创
1502

VBA代码设置单元格或选择区域的格式
可以通过 NumberFormatLocal 属性来设置格式,以下是常用的格式代码


   Selection.NumberFormatLocal ="G/通用格式"   '常规
   Selection.NumberFormatLocal = "0.00_ "  '数值
    Selection.NumberFormatLocal = "¥#,##0.00;¥-#,##0.00" '货币
    Selection.NumberFormatLocal = "_ ¥* #,##0.00_ ;_ ¥* -#,##0.00_ ;_ ¥* " & """" & "-" & """" & "??_ ;_ @_ "  '会计专用
    Selection.NumberFormatLocal = "yyyy/m/d;@" '日期
    Selection.NumberFormatLocal = "[$-409]h:mm:ss AM/PM;@" '时间
    Selection.NumberFormatLocal = "0.00%" '百分比
    Selection.NumberFormatLocal = "# ?/?" '分数
    Selection.NumberFormatLocal = "0.00E+00" '科学记数
    Selection.NumberFormatLocal = "@" '文本
    Selection.NumberFormatLocal = "000000" '特殊
    Selection.NumberFormatLocal = "[DBNum2][$-804]G/通用格式" '中文大写 '特殊
    Selection.NumberFormatLocal = "[DBNum2][$RMB]G/通用格式;[红色][DBNum2][$RMB]G/通用格式" ''特殊人民币大写
    Selection.NumberFormatLocal = "yyyy/mm/dd" '日期 '自定义

分享