I need to set cell background colors in vba. I've got a lot of variables that makes it cumbersome to use conditional formatting. I need some help in understanding the color codes.
I used the macro recorder to see how a background color is set. I chose a bright yellow color and the macro came back with a color code:
Range("G7").Select
With Selection.Font
.Name = "Tahoma"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = True
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
As you can see the color code shows 5296274 and I don't see that type number anywhere I've looked. How can I find the correct codes to use in setting other cells and other colors?
Also - when I go to the 'custom colors' in excel and set the red, green and blue values to red: 255 green 255 blue 0 - I get the bright yellow but the 5296274 doesn't fit - each one (red,green,blue) values have a maximum setting of 255??
Thanks for any help
Bookmarks