Information on color matching
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Information on color matching

  1. #1
    New Member
    Join Date
    Feb 2002
    Location
    Texas Instruments
    Posts
    47
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I don't know if this would be useful to anyone, but I had to find out how to match the background color of controls on my spreadsheet to the sheet's fill color and here's what I learned about the color format:

    Making background color values of controls match the spreadsheet fill color.

    1. Fill spreadsheet with color of your choice from indexed colors
    2. Find out which index color it is
    ?ActiveWorkbook.ActiveSheet.Range("a1").interior.colorindex
    =33
    3. Find out the long decimal value for the color
    ?activeworkbook.Colors(33)
    =16763904
    4. Convert the decimal number to hex using the windows calculator app.
    =FFCC00
    5. Add padding byte 00 to start of the hex number
    =00FFCC00
    6. Add VB hex signifier &H before and & after the number
    7. Paste the value into the background property of the controls on the worksheet.

    Number format: &H00000000&
    ^^
    padding

    Colors are entered as BGR order not RGB

    RGB to long hex conversion:

    Color RGB(0,204,255)

    Dec Hex
    Red 0 00
    Green 204 CC
    Blue 255 FF

    Result: &H00FFCC00&

  2. #2
    New Member
    Join Date
    Feb 2002
    Location
    Texas Instruments
    Posts
    47
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Please excuse the formatting problem of my post. The tabs didn't show up correctly.
    I suppose a person could also alter a color in the pallete to match the control's background color.

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thanks for sharing this. One thing (To save you one step), instead of ColorIndex use Color, like this:

    Range("A1").Interior.Color

    which would return the Long value of the color.
    Regards,

    Juan Pablo González
    http://www.juanpg.com

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com