Excel VBA中的.NumberFormat选项是什么? [英] What are .NumberFormat Options In Excel VBA?
本文介绍了Excel VBA中的.NumberFormat选项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
.NumberFormat
格式选项是什么?您完全知道Excel 2010支持以下类型:
我知道我们可以将文本类型设置为:
.NumberFormat =@
或数字:
.NumberFormat =0.00000
你可以让我知道VBA中的其他类型的选项是什么?
解决方案
在Excel for Mac 2011上,但对于Windows应该相同
宏:
子数字格式()
Dim rng As Range
设置rng =范围(A24:A35)
每个c在rng
Debug.Print c.NumberFormat
Next c
End Sub
结果:
General General
Number 0
货币$#,## 0.00; [Red] $#,## 0.00
会计_ ($ *#,## 0.00 _); _($ *(#,## 0.00); _($ * - ?? _); _(@_)
日期m / d / yy
时间[$ -F400] h:mm:ss am / pm
百分比0.00%
分数#?/?
科学0.00E + 00
文本@
特殊;
自定义#,## 0 _); [红色](#,## 0)
(我刚刚为自定义选择了一个随机条目)
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 ="@"
or for number:
.NumberFormat = "0.00000"
Can you please let me know what are other options for types in VBA?
解决方案
Note this was done on Excel for Mac 2011 but should be same for Windows
Macro:
Sub numberformats()
Dim rng As Range
Set rng = Range("A24:A35")
For Each c In rng
Debug.Print c.NumberFormat
Next c
End Sub
Result:
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屋!
查看全文