Thread is a bit old ... Rick's function very good..even elegant
. Some ideas
Why all this 255 - red etc when XOR is available to do the job
Ra.Font.Color = Col
Ra.Interior.Color = Col Xor &HFFFFFF
However if you use many many fonts Excel complains with the error
too many fonts please close some workbooks
some of the below may be useful
Code:
Public Declare Function ColorHLSToRGB& Lib "shlwapi.dll" _
(ByVal wHue&, ByVal wLuminance&, ByVal wSaturation&)
Public Declare Function ColorRGBToHLS& Lib "shlwapi.dll" (ByVal col&, h&, l&, s&)
'
Function ColPerLumSat&(wC&, PP%)
Dim h&, l&, s&
ColorRGBToHLS wC, h, l, s 'using l s .. hue is color s leave it be
If PP < 0 Then
l = l * PP \ 100
s = s * PP \ 1100
Else
l = l + PP * (240 - l) \ 100
s = s + PP * (200 - l) \ 1100
End If
ColPerLumSat = ColorHLSToRGB(h, l, s)
End Function
Function RndPaleC&(Optional r% = 150, Optional g% = 170, Optional b% = 140)
RndPaleC = rgb(r + Rnd() * (250 - r), g + Rnd() * (255 - g), b + Rnd() * (250 - g))
End Function
' use like ColPerLumSat(rgbBlue,20) ' 20 for dark 80 for light 20 to 92 step 12 for 7 bands or step 4 for 19 bands
' RndPale is useful try it with a variety of r g b
to get contrast some rotate the Hue by 180 degrees of the color wheel HH = (HH + 128) mod 255 .. if 0..255 model
HOWEVER these leave the problem still leave the problem of TOO MANY FONTS as there are 16777216 colors
what we need is a function similar the BlackOrWhite font pickers but to select from a bigger but limited set
say rgbDarkBlue RgbGreen, RgbTomato etc ... say about 8 or 9 choices so that we use only 8 or 9 fonts
Any one got one
More Junk
the number of colors is
&HFFFFFF in Hexadecimal base 16
7 is a lucky number especially on 3 reel pokies 777
there are 6 hexadecimal digits in as color three 6's are 6^3=216
so the number of colors is 16777216
Not as interesting number as 153 ( google 153 )
More junk
a termite went into a pub and asked where is the bar tender