Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

 
 
Help and How-to
Search
Search
 
 
 
 
Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Change cell background color using VBA
 
Applies to
Microsoft Office Excel 2003

Mr. Excel logo

This article was adapted from MrExcel.com. Visit the MrExcel.com Web site for more tips and information.

How can you modify the background color of a cell by using Visual Basic for Applications (VBA)?

You have to use the Interior property of the cell, and then:

  • You can use ColorIndex (to use one of the 56 "preset" colors in Excel):
    ActiveCell.Interior.ColorIndex = 36

  • Or you can use Color:
    Range("A1:A6").Interior.Color = RGB(200,160,35)

advertisement