I have a bunch of code in excel macro which includes following pattern ;

Sheet1.Cells(i, 1).Interior.ColorIndex = 4
Sheet1.Cells(j, 1).Interior.ColorIndex = 4

As you see, I'm painting some cells with color value 4 in my code. But there are only 56 colors in color palette that I can use. I would like to transform the code in order to use RGB (R, G, B) format which will let me use more than 56 colors.

Does somebody know how to transform my code properly? Thanks...


To use RGB you simply use

Sheet1.Cells(i, 1).Interior.Color = RGB(0,255,0)

You can then review this site, which shows you the color index, the HEX and the RGB equivalent of each


So, in the example above this is the same as Color.Index 4 (green)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.