View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
ker_01 ker_01 is offline
external usenet poster
 
Posts: 395
Default Using VBA to gradually change cell interior colors...?

I recently asked a very similar question; you might find the responses useful:

http://www.microsoft.com/communities...r=US&sloc=&p=1

HTH,
Keith

"ShadowedFlames" wrote:

I'm working on a financial project for my employer, and I'm looking for a
different way to gradually change the cell color based on a percentage
instead of the arbitrary "default style + 3 conditions" type brought about by
Conditional Formatting. Please keep in mind that I've not worked with Visual
Basic at all, and haven't even touched the BASIC/QBASIC language in over a
decade. I'm also using Excel 2003 at work with the capability of reading a
2007 file format (which I use on my home computer, if the situation warrants
it).

What I'm aiming for is something akin to this: when the full amount of
funds is available for a project, I would like the background color to be set
to RGB (0, 255, 0). As funds are taken away, the percentage of funds
remaining would affect the G value so that as more funds are used, the cell
background color slowly starts to fade to black.

Examples:
84.7% remaining: 255 * .847 = 215.985 (truncated to 215). RGB = (0, 215, 0)
48.7% remaining: 255 * .487 = 124.185 (truncated to 124). RGB = (0, 124, 0)
11.1% remaining: 255 * .111 = 28.305 (truncated to 28). RGB = (0, 28, 0)
and so on....

Is there a way to effect this using VBA coding, or am I going to have to be
satisfied with the three-tier effect of Conditional formatting?