Return to VBA Code Examples

VBA Cell Font – Change Color, Size, Mode, & More than

In this Commodity

  • VBA Cell Font
  • Alter Font Color
    • vbColor
    • Color – RGB
    • ColorIndex
  • Font Size
  • Bold Font
  • Font Proper name
  • Cell Style

VBA Cell Font

In VBA, y'all can change font properties using the VBA Font Holding of the Range Object. Type the post-obit code into the VBA Editor and y'all'll see a list of all the options available:

vba cell font

Nosotros will discuss a few of the most mutual properties below.

Modify Font Color

There are a few means to fix font colors.

vbColor

The easiest way to prepare colors is with vbColors:

However, y'all're very limited in terms of colors available. These are the but options available:

vba vbcolor

Colour – RGB

You can besides set colors based on RGB (Red Green Blueish). Here yous enter color values between 0-255 for Cherry, Light-green, and Bluish. Using those three colors y'all tin make any colour:

ColorIndex

VBA / Excel also has a ColorIndex property. This makes pre-built colors bachelor to you. However, they're stored every bit Index numbers, which makes information technology hard to know what colour is what:

We wrote an article virtually VBA Colour codes, including a listing of the VBA ColorIndex codes. At that place yous can acquire more about colors.

Font Size

This will ready the font size to 12:

or to sixteen:

VBA Coding Made Easy

Finish searching for VBA code online. Learn more well-nigh AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! automacro

Larn More!!

Assuming Font

It is easy to set a cell font to Bold:

or to clear Bold formatting:

Font Proper noun

To modify a font proper noun use the Name belongings:

Cell Style

Excel offers the ability to create Cell "Styles". Styles can be found in the Domicile Ribbon > Styles:

excel vba font styles

Styles allow you lot to relieve your desired Jail cell Formatting. Then assign that mode to a new cell and all of the cell formatting is instantly applied.  Including Font size, cell colour, cell protections status, and anything else bachelor from the Cell Formatting Menu:

cell formatting menu excel

Personally, for many of the models that I work on, I unremarkably create an "Input" cell way:

By using styles you can as well hands place prison cell types on your worksheet.  The example below will loop through all the cells in the worksheet and change any cell with Style = "Input" to "InputLocked":