VBA, Excel Font Formatting
This article explains the different font formatting options applicable to cells and ranges using VBA. Each section provides a link to a more detailed explanation with VBA code samples.
When you right click a cell and select Format Cells a dialog will open:
The Font tab has all the possible formatting options applicable to cells:
Jump To:
- Bold Font Style (Font.Bold & Font.FontStyle)
- Underline Font Style (Font.Underline)
- Font Type, Font.Name
- Font Color, Font.Color
- Font Size, Font.Size
- Font Strikethrough
- Font Superscript
- Font Subscript
Contents
Font Styles:
The Font Styles formatting option applies to the options provided by the list box marked in the figure below:
Using VBA you can do the following:
- Change the font style
- Bold
- Italic
- Bold and Italic
- Regular
- Get the font style currently used in a cell or range
For sample codes and more information about using Font Styles in VBA please see the links below:
Underline Font Style (Font.Underline):
The Underline font style applies to the formatting options provided by the drop down list marked in the figure below:
Using VBA you can do the following:
- Add an underline
- Single
- Double
- Sinle Accounting
- Double Accounting
- Get the current underline style used in a cell or range
For more information about using underlines in VBA please see the links below:
For sample codes using underlines in VBA please see:
Font Type, Font.Name:
The font type applies to the formatting options provided by the list box marked in the figure below:
Using VBA you can do the following:
- Change the font used in a cell or range
- Get the current font type used in a cell or range
For sample codes and more information about working with fonts in VBA please see the links below:
Font Color, Font.Color:
The font color applies to the formatting options provided by the color drop down list marked in the figure below:
Using VBA you can do the following:
- Change the font color of a a cell or range
- Get the current font color used in a cell or range
For sample codes and more information about working with font colors in VBA please see the links below:
Font Size, Font.Size:
The font size applies to the formatting options provided by the list box marked in the figure below:
Using VBA you can do the following:
- Change the font size of a cell or range
- Get the current font size used in a cell or range
For sample codes and more information about working with font size in VBA please see the links below:
Font Strikethrough:
The font strikethrough effect applies to the formatting option provided by the checkbox marked below:
Using VBA you can do the following:
- Add and remove the strikethrough effect from cells and ranges
- Check whether the strikethrough effect is currently active in a cell or range.
For sample codes and more information on this topic please see the link below:
Font Superscript:
The font superscript effect applies to the formatting option provided by the checkbox marked below:
Using VBA you can do the following:
- Add and remove the superscript effect from cells and ranges
- Check whether the superscript effect is currently active in a cell or range.
For sample codes and more information on this topic please see the link below:
Font Subscript:
The font superscript effect applies to the formatting option provided by the checkbox marked below:
Using VBA you can do the following:
- Add and remove the subscript effect from cells and ranges
- Check whether the subscript effect is currently active in a cell or range.
For sample codes and more information on this topic please see the link below:
See Also:
If you need assistance with your code, or you are looking to hire a VBA programmer feel free to contact me. Also please visit my website www.software-solutions-online.com