Excel VBA 中的 .NumberFormat 选项是什么? [英] What are .NumberFormat Options In Excel VBA?

查看:47
本文介绍了Excel VBA 中的 .NumberFormat 选项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否请您告诉我 Excel VBA 中的 .NumberFormat 格式选项是什么?如您所知,Excel 2010 支持以下类型:

Can you please let me know what are the .NumberFormat format options in Excel VBA? As you are fully aware Excel 2010 supports the following types:

我知道我们可以将文本类型设置为:

I know that we can set for example Text type as:

.NumberFormat ="@"

或数字:

.NumberFormat = "0.00000"

能否请您告诉我 VBA 中的类型还有哪些其他选项?

Can you please let me know what are other options for types in VBA?

推荐答案

注意这是在 Excel for Mac 2011 上完成的,但在 Windows 上应该相同

Note this was done on Excel for Mac 2011 but should be same for Windows

宏:

Sub numberformats()
  Dim rng As Range
  Set rng = Range("A24:A35")
  For Each c In rng
    Debug.Print c.NumberFormat
  Next c
End Sub

结果:

General     General
Number      0
Currency    $#,##0.00;[Red]$#,##0.00
Accounting  _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)
Date        m/d/yy
Time        [$-F400]h:mm:ss am/pm
Percentage  0.00%
Fraction    # ?/?
Scientific  0.00E+00
Text        @
Special     ;;
Custom      #,##0_);[Red](#,##0)

(我只是随机选择了一个自定义条目)

(I just picked a random entry for custom)

这篇关于Excel VBA 中的 .NumberFormat 选项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆