Font Name
The value of Font Name property can be set to one of the fonts: Calibri, Times new Roman, Arial...
The following code sets the font name of range A1:A5 to Calibri.
Range("A1:A5").Font.Name = "Calibri"
Font Style
The value of Font FontStyle property can be set to one of the constants: Regular, Bold, Italic, Bold Italic.
The following code sets the font style of range A1:A5 to Italic.
Range("A1:A5").Font.FontStyle = "Italic"
Font Size
The value of Font Size property can be set to an integer value from 1 to 409.
The following code sets the font size of cell A1 to 14.
Range("A1").Font.Size = 14
Underline
The value of Font Underline property can be set to one of the XlUnderlineStyle constants.
Name | Value | Description |
---|---|---|
xlUnderlineStyleDouble | -4119 | Double thick underline. |
xlUnderlineStyleDoubleAccounting | 5 | Two thin underlines placed close together. |
xlUnderlineStyleNone | -4142 | No underlining. |
xlUnderlineStyleSingle | 2 | Single underlining. |
xlUnderlineStyleSingleAccounting | 4 | Not supported. |
The following code sets the font of cell A1 to xlUnderlineStyleDouble (double underline).
Range("A1").Font.Underline = xlUnderlineStyleDouble
Font Color
The value of Font Color property can be set to:
- Color constants: vbBlack, vbRed, vbGreen, vbYellow, vbBlue, vbMagenta, vbCyan, vbWhite.
- An integer value from 0 to 16,581,375 (RGB color value, 255 * 255 * 255).
- RGB function.
- XlRgbColor.
The following code sets the font color of cell A1 to vbBlack (Black).
Range("A1").Font.Color = vbBlack
The following code sets the font color of cell A1 to 0 (Black).
Range("A1").Font.Color = 0
The following code sets the font color of cell A1 to RGB(0, 0, 0) (Black).
Range("A1").Font.Color = RGB(0, 0, 0)
The following code use XlRgbColor sets the font color of cell A1 to rgbBlue (Blue).
Range("A1").Font.Color = rgbBlue
Font Effects
Strikethrough
True if the font is struck through with a horizontal line.
The following code sets the font of cell A1 to strikethrough.
Range("A1").Font.Strikethrough = True
Subscript
True if the font is formatted as subscript. False by default.
The following code sets the font of cell A1 to Subscript.
Range("A1").Font.Subscript = True
Superscript
True if the font is formatted as superscript; False by default.
The following code sets the font of cell A1 to Superscript.
Range("A1").Font.Superscript = True