Thread
:
Excel 2003 - Color codes
View Single Post
#
4
Posted to microsoft.public.excel.programming
thomas
external usenet poster
Posts: 12
Re : Excel 2003 - Color codes
Many thanks
I now better understand
"Peter T" <peter_t@discussions a écrit dans le message de groupe de
discussion :
...
The palette only contains 56 colours, in a default palette there are 10
duplicates. If you attempt to apply your own RGB Excel will match it to the
closest it can find in the palette.
Your particular RGB example does exist in a default palette, so if index 35
has not been customized you will get a perfect match.
If you want to be sure your colour is applied, but only customize a palette
colour if necessary you could do something like this
colVal = RGB(234, 255, 234) ' very pale green
With Range("a1").Interior
.Color = colVal
If .Color < colVal Then
' the RGB doesn't exist
ActiveWorkbook.Colors(25) = colVal
.ColorIndex = 25
End If
End With
Of course you'd need to be sure you are not messing with someones carefully
customized colour.
Regards,
Peter T
"thomas" <nomail wrote in message
...
Hello,
I was using the colorindex of the palette in my vba code (2003) but it's
not
convenient because it gives different colors when the vba code is used on
excel workbooks with a different palette
I though i would get the same color whatever the palette by using RGB
codes
instead but i have the same problem : For example, RGB (204, 255, 204)
gives
different colors in different workbooks
How can i get always the same colors?
Thanks
Reply With Quote
thomas
View Public Profile
Find all posts by thomas