Class Font (Excel VBA)

Contains the font attributes (font name, font size, color, and so on) for an object.


Background returns or sets the type of background for text used in charts. Read/write Variant, which is set to one of the constants of XlBackground.

Sub UseBackground() 
 With Worksheets(1).ChartObjects(1).Chart 
 .HasTitle = True 
 .ChartTitle.Text = "Rainfall Totals by Month" 
 With .ChartTitle.Font 
 .Size = 10 
 .Background = xlBackgroundTransparent 
 End With 
 End With 
End Sub

Bold true if the font is bold.

Worksheets("Sheet1").Range("A1:A5").Font.Bold = True

Color returns or sets the primary color of the object, as shown in the table in the remarks section. Use the RGB function to create a color value.

Charts("Chart1").Axes(xlValue).TickLabels.Font.Color = _ 
 RGB(0, 255, 0)

ColorIndex returns or sets a value that represents the color of the font.

Worksheets("Sheet1").Range("A1").Font.ColorIndex = 3

FontStyle returns or sets the font style. Read/write String.

Worksheets("Sheet1").Range("A1").Font.FontStyle = "Bold Italic"

Italic true if the font style is italic. Read/write Boolean.

Worksheets("Sheet1").Range("A1:A5").Font.Italic = True

Name returns or sets a Variant value that represents the name of the string.

Parent returns the parent object for the specified object. Read-only.

Size returns or sets the size of the font.

With Worksheets("Sheet1").Range("A1:D10") 
 .Value = "Test" 
 .Font.Size = 12 
End With 

Strikethrough true if the font is struck through with a horizontal line. Read/write Boolean.

ActiveCell.Font.Strikethrough = True

Subscript true if the font is formatted as subscript. False by default.

Worksheets("Sheet1").Range("A1") _ 
 .Characters(2, 1).Font.Subscript = True

Superscript true if the font is formatted as superscript; False by default.

n = Worksheets("Sheet1").Range("A1").Characters.Count 
Worksheets("Sheet1").Range("A1") _ 
 .Characters(n, 1).Font.Superscript = True

ThemeColor returns or sets the theme color in the applied color scheme that is associated with the specified object.

ThemeFont returns or sets the theme font in the applied font scheme that is associated with the specified object.

TintAndShade returns or sets a Single that lightens or darkens a color.

Underline returns or sets the type of underline applied to the font.

ActiveCell.Font.Underline = xlUnderlineStyleSingle