Name

range.NumberFormat

Synopsis

Sets or returns the number formatting for the specified range. Returns Null if the range has mixed formats. The format code corresponds to the Format Codes option in the Format Cells dialog box. The following code changes the color of the specified range to red:

Dim w As Worksheet
 
Set w = Worksheets("WombatBattingAverages")
w.Range("B1:B5").NumberFormat = "#.000"

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.