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?
VBA stands for Visual Basic Analysis. Excel VBA is Microsoft's programming language for Office applications such as MS-Excel, MS-Word, and MS-Access. Macros are what most people who write VBA code use.
The Formula property is a member of the Range object in VBA. We can use it to set/create a formula for a single cell or range of cells. There are a few requirements for the value of the formula that we set with the Formula property: The formula is a string of text that is wrapped in quotation marks.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With