How to set Microsoft Excel cell background color in VBA

Recently I have been working on a VBA project, so I will post some skills or tips I learned and used on Excel VBA program. Today I will share how to change the cell background color in the VBA module.

The property of background color is , and the color is used as Index format. So to setup a cell (row ID: 1, column ID: 12) in Red background color is the below:

Worksheets(1).Cells(1,12).Interior.ColorIndex = 3 ‘change the background color to RED

And you can find more color index in the rest of my post.

    Aqua = 42
    Black = 1
    Blue = 5
    BlueGray = 47
    BrightGreen = 4
    Brown = 53
    Cream = 19
    DarkBlue = 11
    DarkGreen = 51
    DarkPurple = 21
    DarkRed = 9
    DarkTeal = 49
    DarkYellow = 12
    Gold = 44
    Gray25 = 15
    Gray40 = 48
    Gray50 = 16
    Gray80 = 56
    Green = 10
    Indigo = 55
    Lavender = 39
    LightBlue = 41
    LightGreen = 35
    LightLavender = 24
    LightOrange = 45
    LightTurquoise = 20
    LightYellow = 36
    Lime = 43
    NavyBlue = 23
    OliveGreen = 52
    Orange = 46
    PaleBlue = 37
    Pink = 7
    Plum = 18
    PowderBlue = 17
    Red = 3
    Rose = 38
    Salmon = 22
    SeaGreen = 50
    SkyBlue = 33
    Tan = 40
    Teal = 14
    Turquoise = 8
    Violet = 13
    White = 2
    Yellow = 6

Leave a Reply

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

Please Answer: * Time limit is exhausted. Please reload the CAPTCHA.