office交流網--QQ交流群號

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

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

VBA代碼設置單元格或選擇區域的格式NumberFormatLocal

2020-05-22 08:00:00
zstmtony
原創
25447

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" '日期 '自定義

分享