NumberFormat Property

Applies To

DataLabel Object, DataLabels Collection, PivotField Object, Range Object, Style Object, TickLabels Object.

Description

Returns or sets the format code for the object (as a string). Read-write.

Remarks

For the PivotField object, the NumberFormat property can be set only for a data field.

The format code is the same string as the Format Codes option in the Format Cells dialog box. The Format function uses different format code strings than the NumberFormat and NumberFormatLocal properties.

See Also

NumberFormatLinked Property, NumberFormatLocal Property.

Example

These examples set the number format for cell A17, row one, and column C on Sheet1.


Worksheets("Sheet1").Range("A17").NumberFormat = "General"
Worksheets("Sheet1").Rows(1).NumberFormat = "hh:mm:ss"
Worksheets("Sheet1").Columns("C").NumberFormat = _
    "$#,##0.00_);[Red]($#,##0.00)"