Consulting

Results 1 to 4 of 4

Thread: Solved: Excel Color Palettes

  1. #1

    Solved: Excel Color Palettes

    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??

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Quote Originally Posted by Cyberdude
    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 to see what color indexes refer to what colors.

  3. #3
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by DRJ
    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 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.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  4. #4
    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!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •