LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Generating an RGB color spectrum based on cell values (XL03)

I have a (26 x 60+) grid of values . I need to be able to visually identify
repeat values, so I'm looping through the cells and assigning a color based
on the value. To be as efficient as possible, I decided to use the cell value
to drive the color code directly; I don't care what number gets what color,
as long as adjacent numbers don't get the same (or similar) color.

The grid values range from 1 to 80 (integers). Adjacent cells are very
likely to have adjacent values (e.g. 1 and 2, 2, and 3) up to a spread of
about 4 (or so) at one corner of the grid.

A B C D E F G H
1. 1 1 2 2 3 4 4 5
2. 1 1 2 3 3 4 5 6
3. 1 2 3 3 4 5 6 7
4. 2 3 3 4 5 6 6 8
5. 2 3 4 5 6 7 7 8
etc

so I'm trying to find intervals of RGB values based on the cell value so
that I can create the spectrum (repeat colors are fine, as long as there are
at least a few colors inbetween for visual separation). I'm trying different
versions of the code below, where I'm modifying the multiplier used (5, 10,
15, 20, etc) with sVal but I'm still getting situations where similar values
(such as 1 and 2) end up with the same color (does Excel round to the nearest
color on the pallet?).

I'm not real familiar with the RGB color wheel as it relates to the numbers
and whatever colors Excel then uses, so I'm looking for advice on how to fix
that one line to ensure that I won't have adjacent cells with the same color
but different numbers.

Many thanks,
Keith

Sub ColorizeRanges()
Dim iCol As Long

For iRow = 3 To 41
For iCol = 2 To 27
uCol = ColLetter(iCol) 'separate function, returns column C to AA
sVal = (Sheet5.Range(uCol & iRow).Value)

'this is the key line:
Sheet5.Range(uCol & iRow).Interior.Color = RGB(250 - ((20 * sVal)
Mod 250), 250 - ((35 * sVal) Mod 250), ((20 * sVal) Mod 250))

Next
Next
End Sub


 
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
cell fill color spectrum Matthew Dyer Excel Programming 5 January 12th 10 10:12 PM
Change formulas into values based on cell color Aria[_2_] Excel Programming 2 October 23rd 06 10:55 PM
Q: How to color a cell based on values in two cells abcd1234 Excel Programming 17 March 13th 06 02:03 PM
In excell be able to Sum values based on the color of the cell Ray Lewis Excel Worksheet Functions 0 October 5th 05 03:10 PM
Problems generating an html link based on worksheet values Frederik Romanov Excel Programming 0 July 1st 03 02:24 PM


All times are GMT +1. The time now is 01:54 PM.

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"