ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Science & Programming»
  • Programming Languages

VBA: How to Change Excel Font and Cell Background Color

Updated on September 11, 2012

Changing Font Color

Changing the color a font in excel is fairly easy and straight forward test.

  • Select the cell or range
  • Right Click
  • Select Format Cells

  • Click on the font tab
  • Find the color field
  • Click the drop down button

Notice you have the choice of picking from a variety of preset colors. You also have the option of selecting custom color. This will take you to a color wheel where you can pick the exact color you want.

Changing Cell Background Color

The background color is also change within the cell format toolbox.

  • Click the fill tab.
  • Select desired color.

Notice again the option for more colors, once again this will take you to a color wheel where you can select any color you want. See below for illustration.

Notice how you color is defined by Red, Green, and Blue coordinates. This is how you will define your color within VBA.

Change Font Color VBA

'Change Color of Range "A1" to the green defined above

Range("A1").Font.Color = RGB(59, 179, 73)

Change Background Color VBA

'Change color of Background of Range "A1" to green color define above

Range("A1").Interior.Color = RGB(59, 179, 73)

A Test Macro

Sub test()
Range("A1") = "Fun"
Range("A1").Font.Size = 72
Range("A1").Interior.Color = RGB(59, 179, 73)
Range("A2") = "With"
Range("A2").Font.Size = 72
Range("A2").Font.Color = RGB(99, 179, 73)
Range("A3") = "Colors"
Range("A3").Font.Size = 72
Range("A3").Font.Color = RGB(99, 179, 73)
Range("A3").Interior.Color = RGB(0, 0, 0)
End Sub

Ready to Proceed?

You will notice the font is too large for the column. We will soon learn to set the width of columns and use autofit, but first lets learn how to select and reference columns and rows within Excel and Visual Basic.


    0 of 8192 characters used
    Post Comment

    • profile image

      Johng849 3 years ago

      Article Source a viral game app is not that much affdakekkedc

    • profile image

      marot90 4 years ago from Munich, Germany

      Color-Coding looks nice, and has positive effects too. Enhanced readability for example. You can even filter and sort cells by color (not by Font-color though, at least not as far as i know). You just have to click on the "filter" button, and then select filter or sort by color, where you have the choice of all currently used background colors within your sheet. For the sake of easier explanation, here is the guide i learned that from: . Might help newer users, though it is fairly easy to do on your own, once you know about the excel filter. EDIT: Thanks of course for providing us with VBA knowledge about color and Fonts in excel.