Place three command buttons on your worksheet and add the following code lines:
1. The code line below sets the background color of cell A1 to light blue.
Range("A1").Interior.ColorIndex = 37Result:
2. The following code line sets the background color of cell A1 to 'No Fill'.
Range("A1").Interior.ColorIndex = 0Result:
3. If you want to know the ColorIndex number of a color, simply ask Excel VBA.
MsgBox Selection.Interior.ColorIndex
Select cell A1 and click the command button on the sheet:
4. The ColorIndex property gives access to 56 "preset" colors. If you can't find the specific color you are looking for, use the Color property and the RGB function.
Range("A1").Interior.Color = RGB(255, 0, 0)Explanation: RGB stands for Red, Green and Blue. These are the three primary colors. Each component can take on a value from 0 to 255. With this function you can make every color. RGB(255,0,0) gives the pure Red color (exact same result as above)..