Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are .NumberFormat Options In Excel VBA?

Tags:

excel

vba

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:

enter image description here

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?

like image 403
user1760110 Avatar asked Dec 18 '13 01:12

user1760110


People also ask

What are Vbas in Excel?

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.

What does .formula do in VBA?

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.


1 Answers

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)

like image 95
doovers Avatar answered Sep 24 '22 02:09

doovers