Set cell background color programmatically

The VBA code line you should use when you need to set a new background color to a cell is:

Sheets(“Sheet1”).Range(“C3”).Interior.Color = RGB(255, 255, 0)

RGB(255, 255, 0) = Yellow (full Red and full Green)

Where RGB defines the color you need as a mix of 3 color:Red Green and Blue (RGB).

Zero means no color and 255 means full color. Between 0 and 255 with the 3 color settings you can obtain any color you wish.

For other colors please see the color map article.


Author has written 295 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.