Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Programatically dim (lighten the color) of a cell.

I know I can read the RGB value of a color in VBA.

Is there a consistent way to do a calculation on those values to visually
return the same color but lighter (dimmer)?

Thanks,
Jeremy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Programatically dim (lighten the color) of a cell.

Excel only displays 56 colors at a time. The color value is RGB, but it
won't be the RGB value you set unless are just lucky. It sets the value to
the closest color to the RGB value.

If you go into Tools=Options=Color Tab, you will see there are very few
colors I would call dimmer shades of other colors in the palette. You can
create your own custom palette of course.

See David McRitchie's page on this:
http://www.mvps.org/dmcritchie/excel/colors.htm

--
Regards,
Tom Ogilvy


"Jeremy Gollehon" wrote in message
...
I know I can read the RGB value of a color in VBA.

Is there a consistent way to do a calculation on those values to visually
return the same color but lighter (dimmer)?

Thanks,
Jeremy






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Programatically dim (lighten the color) of a cell.

Hi Tom,
Thanks for the reply.
Let me reword this a little (It should really have a different title).

Lets say I want to change the color of [Color 47] (RGB 102,102,153) in the
color pallete.
Currently I can go to Tools Options Color Modify Custom, and slide
the slider up a little to get a lighter color.

Is there a way to do this programatically?
The real problem is that depending on where you start in the color range,
the percentage change in Red, Green, or Blue is different as you move the
slider. I was hoping someone out there might have tackled something like
this before.

Thanks again,
Jeremy


Tom Ogilvy wrote:
Excel only displays 56 colors at a time. The color value is RGB, but
it won't be the RGB value you set unless are just lucky. It sets the
value to the closest color to the RGB value.

If you go into Tools=Options=Color Tab, you will see there are very
few colors I would call dimmer shades of other colors in the palette.
You can create your own custom palette of course.

See David McRitchie's page on this:
http://www.mvps.org/dmcritchie/excel/colors.htm


"Jeremy Gollehon" wrote in message
...
I know I can read the RGB value of a color in VBA.

Is there a consistent way to do a calculation on those values to
visually return the same color but lighter (dimmer)?

Thanks,
Jeremy



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Programatically dim (lighten the color) of a cell.

Hi Jeremy

I know I can read the RGB value of a color in VBA.


If you use customized palette colours be sure to read the RGB of the color
index and not the RGB of some format. Otherwise you may return the default
palette colour rather than the actual colour (depends on other factors
related in your overall code).

Is there a consistent way to do a calculation on those values to visually
return the same color but lighter (dimmer)?


Depending on what you mean by making lighter/darker it probably involves
converting RGB to HSL, adjusting the L value +/- then reconverting the new
HSL to RGB. Then perhaps customizing one of the palette colours with the new
RGB.

But if all you want to do is format a similar colour lighter/darker a crude
way is mixing pattern "grey" shades with pattern colour white through grey
to black. If you want to go further over 2000 unique colours can be
"simulated" using pattern shades with the default palette of 46 unique
colours (56-10 duplicates).

Regards,
Peter T

"Jeremy Gollehon" wrote in message
...
I know I can read the RGB value of a color in VBA.

Is there a consistent way to do a calculation on those values to visually
return the same color but lighter (dimmer)?

Thanks,
Jeremy




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Programatically dim (lighten the color) of a cell.

Jeremy,

"Is there a way to do this programmatically?"
I think you are looking for...
ActiveWorkbook.Colors(47) = RGB(102, 125, 153)

Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jeremy Gollehon"
wrote in message
...
Hi Tom,
Thanks for the reply.
Let me reword this a little (It should really have a different title).

Lets say I want to change the color of [Color 47] (RGB 102,102,153) in the
color pallete.
Currently I can go to Tools Options Color Modify Custom, and slide
the slider up a little to get a lighter color.

Is there a way to do this programatically?
The real problem is that depending on where you start in the color range,
the percentage change in Red, Green, or Blue is different as you move the
slider. I was hoping someone out there might have tackled something like
this before.
Thanks again,
Jeremy


Tom Ogilvy wrote:
Excel only displays 56 colors at a time. The color value is RGB, but
it won't be the RGB value you set unless are just lucky. It sets the
value to the closest color to the RGB value.

If you go into Tools=Options=Color Tab, you will see there are very
few colors I would call dimmer shades of other colors in the palette.
You can create your own custom palette of course.

See David McRitchie's page on this:
http://www.mvps.org/dmcritchie/excel/colors.htm


"Jeremy Gollehon" wrote in message
...
I know I can read the RGB value of a color in VBA.

Is there a consistent way to do a calculation on those values to
visually return the same color but lighter (dimmer)?

Thanks,
Jeremy





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Programatically dim (lighten the color) of a cell.

Yes! This is more to what I'm getting at Peter.
I'll look into converting RGB to HSL, then adjusting the L, then converting
back to RGB. Without any knowledge beyond what you've said, this sounds
like exactly like what I'm trying to do. It also sounds easier than mixing
pattern grey shades. I'm not sure, but at least now I know where to look
and where to possible point further questions.

Thanks.
-Jeremy

Peter T wrote:
Hi Jeremy

I know I can read the RGB value of a color in VBA.


If you use customized palette colours be sure to read the RGB of the
color index and not the RGB of some format. Otherwise you may return
the default palette colour rather than the actual colour (depends on
other factors related in your overall code).

Is there a consistent way to do a calculation on those values to
visually return the same color but lighter (dimmer)?


Depending on what you mean by making lighter/darker it probably
involves converting RGB to HSL, adjusting the L value +/- then
reconverting the new HSL to RGB. Then perhaps customizing one of the
palette colours with the new RGB.

But if all you want to do is format a similar colour lighter/darker a
crude way is mixing pattern "grey" shades with pattern colour white
through grey to black. If you want to go further over 2000 unique
colours can be "simulated" using pattern shades with the default
palette of 46 unique colours (56-10 duplicates).

Regards,
Peter T

"Jeremy Gollehon" wrote in message
...
I know I can read the RGB value of a color in VBA.

Is there a consistent way to do a calculation on those values to
visually return the same color but lighter (dimmer)?

Thanks,
Jeremy



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing font color of protected cells programatically Nigel Excel Discussion (Misc queries) 6 September 13th 08 12:32 PM
can I lighten background page numbers LA Horowitz Excel Discussion (Misc queries) 2 January 18th 08 02:06 AM
can i access the cell colour programatically? eg if cell is blue Tony2Far Excel Discussion (Misc queries) 2 August 9th 06 06:50 PM
programatically color fonts and auto sorting [email protected] Excel Programming 2 December 26th 05 07:03 AM
Excel: is there a way I can lighten the fill colors in a cell? Bob Tourkow Excel Discussion (Misc queries) 1 September 15th 05 02:27 PM


All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"