PDA

View Full Version : Solved: Excel Color Palettes



Cyberdude
09-16-2005, 12:51 PM
There seems to be two Excel color palettes:
A. The one I see when I click the font or interior color button at the top of my worksheet, and
B. The one that Excel seems to reference when I write a VBA statement to change the colors in a color palette.
The statement:
ActiveWorkbook.Colors(IdxNo) = RGBColor
will change the color of any one of the 56 colors in the color palette. The color palette I see for setting a font color manually is 8 columns wide by 5 rows high. I get two more rows for chart colors. I assume that the index for these colors goes from 1 for the leftmost color on the top row to 8 for the rightmost column on the top row, then down to 9 on the next row, etc.
When I started testing the statement shown above, it worked just fine, except it changed a color in a location other than what I specified. What's the relationship between the two color palettes?? http://vbaexpress.com/forum/images/smilies/banghead.gif

Jacob Hilderbrand
09-16-2005, 01:48 PM
I assume that the index for these colors goes from 1 for the leftmost color on the top row to 8 for the rightmost column on the top row, then down to 9 on the next row, etc.

Well there is your problem. 1) never assume anything, and 2) NEVER EVER assume anything when dealing with Microsoft.

I mean really, if anyone can explain why the Chart Options for a chart are not located in the Chart drop-down? It makes no sense.

In the case of the colors, the color indexes are scattered all over the place. Check this Kb Entry (http://vbaexpress.com/kb/getarticle.php?kb_id=206) to see what color indexes refer to what colors.

MWE
09-16-2005, 02:37 PM
Well there is your problem. 1) never assume anything, and 2) NEVER EVER assume anything when dealing with Microsoft.

I mean really, if anyone can explain why the Chart Options for a chart are not located in the Chart drop-down? It makes no sense.

In the case of the colors, the color indexes are scattered all over the place. Check this Kb Entry (http://vbaexpress.com/kb/getarticle.php?kb_id=206) to see what color indexes refer to what colors.
kudos to DRJ for his reply without resorting to 4 letter words and disbarraging remarks about Bill Gates' ancestors.

The Excel color pallets are a real challenge. Using vbRed, vbBlue, etc can reduce the headaches to modest migrain.:banghead::banghead::banghead:

Cyberdude
09-17-2005, 10:03 AM
Thanks for all those encouraging remarks.
And for my next trick, I'm going to see if I can write something that will map the "user" color palette into the "Excel" color palette. That will make a doosie of an article if I can do it. I think I'll call the user palette "upalette" and the Excel palette "xlpalette". (Phffft!)