+ Reply to Thread
Results 1 to 17 of 17

Excel 2007 : how to get the filled color rgb generated by color scale ?

  1. #1
    Registered User
    Join Date
    09-09-2010
    Location
    Wuhan China
    MS-Off Ver
    Excel 2010, 2003
    Posts
    6

    how to get the filled color rgb generated by color scale ?

    Hi ererybody,

    I apply conditional formatt - color scale to a range in excel 2010, how can I get the background color's rgb vaule through vba?
    Last edited by liu; 09-12-2010 at 08:03 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: how to get the filled color rgb generated by color scale ?

    In Excel 2003, you're limited to the 56-color palette for cell formatting. You can get those by looking at Tools > Options > Color.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: how to get the filled color rgb generated by color scale ?

    This works in 2007, I don't know about 2003, though:
    Please Login or Register  to view this content.
    Last edited by protonLeah; 09-10-2010 at 08:25 PM.
    Ben Van Johnson

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: how to get the filled color rgb generated by color scale ?

    Interesting....

    I am using this
    Please Login or Register  to view this content.

    In most cases it entirely agrees with protonLeahs' solution

    I have however found this exception
    Please Login or Register  to view this content.
    My code returns what seems to be the correct result but PLs' apparentlly cannot differentiate the two.

    Attached is a demo "custom randomized palette" workbook in 2007 (work still in progress)
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-09-2010
    Location
    Wuhan China
    MS-Off Ver
    Excel 2010, 2003
    Posts
    6

    Re: how to get the filled color rgb generated by color scale ?

    shg、protonLeah、Marcol -
    thanks for your reply.
    I use excel 2010, the code can return the manually filled background color , but can't return the background color generated by "color scale".

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: how to get the filled color rgb generated by color scale ?

    If you use 2010 and not 2003 would you please update your profile to say so.

    It can make a big difference to the solution you get offered.

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: how to get the filled color rgb generated by color scale ?

    Hi liu

    Conditional formatting doesn't fill the interior colour a cell, I think it just masks it.

    Try this with a cell that has a C/F colour showing
    Please Login or Register  to view this content.

    I haven't fully tested this yet it might need some adjusting

    [EDIT]
    This returns the basic colour RGB it doesn't handle the various shades.
    Hmmm....???....
    Last edited by Marcol; 09-11-2010 at 12:12 PM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  8. #8
    Registered User
    Join Date
    09-09-2010
    Location
    Wuhan China
    MS-Off Ver
    Excel 2010, 2003
    Posts
    6

    Re: how to get the filled color rgb generated by color scale ?

    Quote Originally Posted by Marcol View Post
    If you use 2010 and not 2003 would you please update your profile to say so.

    It can make a big difference to the solution you get offered.
    Sorry, I just registed my account 2 days ago, I haven't update my profile.

  9. #9
    Registered User
    Join Date
    09-09-2010
    Location
    Wuhan China
    MS-Off Ver
    Excel 2010, 2003
    Posts
    6

    Re: how to get the filled color rgb generated by color scale ?

    Quote Originally Posted by Marcol View Post
    Hi liu

    [EDIT]
    This returns the basic colour RGB it doesn't handle the various shades.
    Hmmm....???....
    yes, it returns the basic colour RGB , not the various.
    Is there any other way?
    Last edited by liu; 09-12-2010 at 09:12 PM.

  10. #10
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: how to get the filled color rgb generated by color scale ?

    Hi liu

    Please don't quote whole posts in your replies, this is not necessary, it just clutters the board and the moderators don't like it.....

    I'm working on it, but haven't found a solution yet. Keep looking in and hopefully I or someone else will have a solution soon.

  11. #11
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: how to get the filled color rgb generated by color scale ?

    Hmmm...
    Please Login or Register  to view this content.

  12. #12
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: how to get the filled color rgb generated by color scale ?

    Hi protonLeah
    Please Login or Register  to view this content.
    Returns the number of times the Cell/Range has been formatted

    For each FCCount there is a ColorScale this has a number of colours, I think 1?,2 or 3 as standard
    Please Login or Register  to view this content.
    eg
    ColorScaleType:=3 Red - Yellow - Blue (Standard Example)
    HTML Code: 
    Then there are the graded values between each colour!
    That's the hard bit, not to difficult if there is a known min/max but if these values are left open that's proving a bit more awkward.

    Then there is the possibility of custom setups.....
    Last edited by Marcol; 09-12-2010 at 10:09 PM. Reason: Red - Yellow - Blue corrected to Red - Yellow - Blue

  13. #13
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: how to get the filled color rgb generated by color scale ?

    I'll have to drink deeply in order to grok that!

  14. #14
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: how to get the filled color rgb generated by color scale ?

    Have one for me, I had a quiet night in the pub tonight, that's probably why I can't think straight...

    I think I'm there with ColorScaleType:=2 gradings, but ColorScaleType:=3 is a bit of a pain, can't get the hang of this additive colour thing....

    [EDIT]
    Error in post #12 corrected, that's what my problem was I was using the wrong scale....

    [EDIT 2]
    Sample worksheet attached for ColorScaleType:=3 Red > Yellow > Blue
    Might help to explain my rantings
    Attached Files Attached Files
    Last edited by Marcol; 09-12-2010 at 10:48 PM.

  15. #15
    Registered User
    Join Date
    09-09-2010
    Location
    Wuhan China
    MS-Off Ver
    Excel 2010, 2003
    Posts
    6

    Re: how to get the filled color rgb generated by color scale ?

    [QUOTE

    this is a litle complicated for me .

    I have 2 manual ways to change the" color scale " color into steady background color,then I can get the bakcground color's rgb. but I don't know how to do that automaticly.

    method 1: copy the " color scale " ranges->goto the target cell->open the Clipboard windows,->choose the right item ->choose "paste". dont use "ctrl+c"and "ctrl+v"

    method 2:copy the " color scale " ranges->open a new word file->paste->copy the tabe in word->goto excel->goto the target cell->paste.

    the problem is, how to do this automaticly?
    Last edited by liu; 09-13-2010 at 10:14 PM.

  16. #16
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: how to get the filled color rgb generated by color scale ?

    Hi liu, sorry about the delay in getting back to you.

    Try this demo workbook

    Select the range you need to evaluate then run the macro "ReturnRGB_CF"
    Please Login or Register  to view this content.

    This could be done with a bit of tidying.

    The idea of copying to Word was a good one, and that is what this solution does.

    I have another solution that doesn't involve Word, but it is not quite there yet, the permutations are a bit awkward, but it will eventually return all the colours for the whole colour scale based on the conditions set, and the max/min values specified.

    Hope this helps in the mean time.
    Attached Files Attached Files
    Last edited by Marcol; 09-14-2010 at 11:22 PM.

  17. #17
    Registered User
    Join Date
    11-21-2012
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Excel 2007 : how to get the filled color rgb generated by color scale ?

    Hi Marcol,
    did you manage to develop an alternative to word copy/paste? If so would you mind sharing it?
    TX

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1