Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert .colorindex to RGB (O2003/WinXP)

    Hi,

    Is there an easy way, perhaps even a function to convert a .colorindex(i) to the actual RGB components...

    Maybe something equivalent to: strRGB =cRGB(Selection.colorindex(i))

    Thanks in advance for any possible hints
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    There is no such thing as .ColorIndex(i).

    If you want to get the ColorIndex of the interior of the current cell, use ActiveCell.Interior.ColorIndex. If you want to retrieve the RGB color of the interior of the current cell, use ActiveCell.Interior.Color.

    If you want to know the RGB value of the n-th color in the color palette of the active workbook, use ActiveWorkbook.Colors(n), as indicated in my replies to your previous thread on this subject.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    Hi Hans,

    Thanks for correcting me on this one / ;o)

    Just thought that a function similar to other convertion functions (eg. cStr) would be useful, but you are perfectly right.

    ... thus, please accept my apologies for asking the same stupid question twice.


    ;o) Henrik
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  4. #4
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    You can however, define the colours by using RGB.
    ActiveWorkbook.Colors(some number between 1 and 56) = RGB(93, 0, 126)
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  5. #5
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    Hi (again)

    Having looked closer at your line: Colors© returns the RGB color value. Black = 0, Red = 255, Green = 256 * 255 = 65280 and Blue = 256 * 256 * 255 = 16711680.
    I must admit that I'm still not 100% sure how you want to turn that into an RGB(x,y,z) value.

    How do I decipher the returned value ??? (eg. In default palette yellow is 65535) - How is that converted into R-G and B components??
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  6. #6
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    Ok, now I'm confused. Perhaps if you mentioned what you want to do with these colours?

    The earlier line of code would allow you to define your own palette for a workbook - so you would know the RGB values of all colours in the palette.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    See attached.

  8. #8
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    Edited by HansV to provide link to post - see <!help=19>Help 19<!/help>

    In a spreadsheet... I would like to be able to extract my at any time current colorpalette and decompose it.

    Intention would be to make a list similar to this...

    Column A: Colorindex number (1 to 56)
    Column B: Actual color (selection.interior.colors(i))
    Column C: Color number (Activeworkbook.colors(i) - the one Hans mentioned initially in a prevous discussion - URL at bottom of this... )
    Column D: RGB (full string)
    Column E: R
    Column F: G
    Column G: B

    <post#=443402>post 443402</post#>
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  9. #9
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    Superb,

    Thank you very much Hans, this was exactly what I was hoping to find...
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  10. #10
    Lounger
    Join Date
    Feb 2001
    Location
    Middletown, New Jersey, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    Here is an updated macro for the same function using the VBA mod funciton

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert .colorindex to RGB (O2003/WinXP)

    Thank you.

Posting Permissions

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