![]() |
Color Variation
I want to have 20 shades of a color. 1 being the darkest, 20 being the
lightest. I am going to use this to color the cell background through code based on the 1 - 20 value. If I use .color = 6684672 as the 1 value, how do I graduate this down to say ..color = 16767449 as the 20 value? |
Color Variation
I usually record a macro and then maually select the colors I want. Then use the color numbers from the recorded macro in my code. the color numbers is a hexidecimal number which is in three parts (Red=0 to 255, Green=0 to 255, Blue=0 to 255). So you could uses Red = 25 Green = 50 Blue = 10 Mycolor = (Red*256*256) + (Green*256) + Blue -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
Do a quick search for functions to convert RGB to HSL, and back again HSL to
RGB, you'll find lots of examples to play with. Having return HS discard the L. Make 20 incremented values between say 0.8 to 0.1 as new L values (0 will be black and 1 white, so don't bother with values near those). With the original H & S and your new Ls make your new RGBs. FWIW, with 20 shades it will be difficult to distinguish them all unless they are placed adjacent, only then are the small shade differences noticeable. Regards, Peter T "Paul W Smith" wrote in message ... I want to have 20 shades of a color. 1 being the darkest, 20 being the lightest. I am going to use this to color the cell background through code based on the 1 - 20 value. If I use .color = 6684672 as the 1 value, how do I graduate this down to say .color = 16767449 as the 20 value? |
Color Variation
Thanks Joel.
I too record macros to get color numbers. However in this instance I can use this meethod to determine to number for the darkest color, but how do I find the number of the next shade.... with the shades graduating on a scale of 1 to 20 with 1 being the darkest and 20 being the lightest? "joel" wrote in message ... I usually record a macro and then maually select the colors I want. Then use the color numbers from the recorded macro in my code. the color numbers is a hexidecimal number which is in three parts (Red=0 to 255, Green=0 to 255, Blue=0 to 255). So you could uses Red = 25 Green = 50 Blue = 10 Mycolor = (Red*256*256) + (Green*256) + Blue -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
Pick 20 different shade in the macro. Don't use colorindex, instead select more colors. Convert the shades to hexidecimal to help you get the inbetween shades MyColor = 10053375 RedShade = int(MyColor/(256*256)) GreenShade = int(MyColor/256) mod 256 BlueShade = MyColor Mod 256 -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
Joel, that doesn't help make same-shade colours light to dark. As I
mentioned, need RGB to HSL to RGB with 20 increments of L but not near 0 or 1 Regards, Peter T "joel" wrote in message ... Pick 20 different shade in the macro. Don't use colorindex, instead select more colors. Convert the shades to hexidecimal to help you get the inbetween shades MyColor = 10053375 RedShade = int(MyColor/(256*256)) GreenShade = int(MyColor/256) mod 256 BlueShade = MyColor Mod 256 -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
Instead of recording a macro to get your colors, try doing this instead. Go
into the VB editor (of a new workbook if you want) and add a UserForm. In the Properties box, select any property that allows color to be set (for example, the BackColor property), then click the down arrow that appear. Next, select the Palette tab on the dialog box that appears and right click one of the 16 white squares at the bottom of the dialog page. This will bring up a color selection panel. You can select the main color you want from the large color selection square and then select the 20 color intensities you want from the thin vertical bar to the right of it. As you select each color intensity, jot down the Red, Green and Blue values for it and then use the 20 jotted down Red, Green and Blue values in VB's RGB function when assigning them. -- Rick (MVP - Excel) "Paul W Smith" wrote in message ... Thanks Joel. I too record macros to get color numbers. However in this instance I can use this meethod to determine to number for the darkest color, but how do I find the number of the next shade.... with the shades graduating on a scale of 1 to 20 with 1 being the darkest and 20 being the lightest? "joel" wrote in message ... I usually record a macro and then maually select the colors I want. Then use the color numbers from the recorded macro in my code. the color numbers is a hexidecimal number which is in three parts (Red=0 to 255, Green=0 to 255, Blue=0 to 255). So you could uses Red = 25 Green = 50 Blue = 10 Mycolor = (Red*256*256) + (Green*256) + Blue -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
I tried to get a even spread of colors. I don't have a great graphics card so I getting with the macro very little spread. Yo may get better results Sub Macro2() Range("a1").Interior.Color = RGB(204, 0, 200) Range("A2").Interior.Color = RGB(204, 0, 190) Range("a3").Interior.Color = RGB(204, 0, 180) Range("a4").Interior.Color = RGB(204, 0, 170) Range("a5").Interior.Color = RGB(204, 0, 160) Range("a6").Interior.Color = RGB(204, 0, 150) Range("a7").Interior.Color = RGB(204, 0, 140) Range("a8").Interior.Color = RGB(204, 0, 130) Range("a9").Interior.Color = RGB(204, 0, 120) Range("a10").Interior.Color = RGB(204, 0, 110) Range("a11").Interior.Color = RGB(204, 0, 100) Range("a12").Interior.Color = RGB(204, 0, 90) Range("a13").Interior.Color = RGB(204, 0, 80) Range("a14").Interior.Color = RGB(204, 0, 70) Range("a15").Interior.Color = RGB(204, 0, 60) Range("a16").Interior.Color = RGB(204, 0, 50) Range("a17").Interior.Color = RGB(204, 0, 40) Range("a18").Interior.Color = RGB(204, 0, 30) Range("a19").Interior.Color = RGB(204, 0, 20) Range("a20").Interior.Color = RGB(204, 0, 10) End Sub -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Definition
How do I convert a color Long - 8210719, RGB(31,73,125) or #1F49FD to
something I can use to format the backcolor of a form control? White = &H80000005& - what sort of value is this? How do I convert any of the above color references to this format? |
Color Variation
MyColor = 8210719 RedShade = int(MyColor/(256*256)) GreenShade = int(MyColor/256) mod 256 BlueShade = MyColor Mod 256 RGB(RedShade,GreenShade,BlueShade) -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
How does this help me?
I need something that I can use to color a control background at run time, so it has to be in the format similar to: &H80000005& You method below turns a Long number into RGB, but I already have RGB, I need the...whatveer the definiton is for the thing that has & signs at each end. "joel" wrote in message ... MyColor = 8210719 RedShade = int(MyColor/(256*256)) GreenShade = int(MyColor/256) mod 256 BlueShade = MyColor Mod 256 RGB(RedShade,GreenShade,BlueShade) -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
That's the constant value for vbWindowbackground, ie a system setting,
typically white. I don't understand your question, you can apply that constant directly. If you want to return the user's system colour(s) it's easy enough with the GetSystemColor API, but you don't need to, at least to set the colour properties of activeX controls. Curiosity, having informed you how to go about getting a range of colour shades why didn't you follow it up. Regards, Peter T "Paul W Smith" wrote in message ... How does this help me? I need something that I can use to color a control background at run time, so it has to be in the format similar to: &H80000005& You method below turns a Long number into RGB, but I already have RGB, I need the...whatveer the definiton is for the thing that has & signs at each end. "joel" wrote in message ... MyColor = 8210719 RedShade = int(MyColor/(256*256)) GreenShade = int(MyColor/256) mod 256 BlueShade = MyColor Mod 256 RGB(RedShade,GreenShade,BlueShade) -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
Sorry Peter I have used the method of getting shades by graduating the L
value. I was doing this from code so having an RGB value was no issue. This is another issue which is why I tried to start another thread (but failed). What I have is a heading area which is a range of cells colored with one of the theme colour. I have as certained that it is : 8210719, RGB(31,73,125) or #1F49FD I want to place a control on this header range of cells and match the control's background color to the color of the cells. Using the proprties on the control I want to set the background color but I cannot find anything that it will accept. It will not accept #1F49FD so what do I do? I know I could write something into the worksheet.activate event that colors the control because this would be doing it vua code, which I can do because I use the RGB function, but surely ther is a better way i coulod do it at design time? "Peter T" <peter_t@discussions wrote in message ... That's the constant value for vbWindowbackground, ie a system setting, typically white. I don't understand your question, you can apply that constant directly. If you want to return the user's system colour(s) it's easy enough with the GetSystemColor API, but you don't need to, at least to set the colour properties of activeX controls. Curiosity, having informed you how to go about getting a range of colour shades why didn't you follow it up. Regards, Peter T "Paul W Smith" wrote in message ... How does this help me? I need something that I can use to color a control background at run time, so it has to be in the format similar to: &H80000005& You method below turns a Long number into RGB, but I already have RGB, I need the...whatveer the definiton is for the thing that has & signs at each end. "joel" wrote in message ... MyColor = 8210719 RedShade = int(MyColor/(256*256)) GreenShade = int(MyColor/256) mod 256 BlueShade = MyColor Mod 256 RGB(RedShade,GreenShade,BlueShade) -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
the number &H80000005& is a hexidecimal number. The 8 indicates the sign bit is set so you really have in bits FFFFFFFB (2's compliment). This isn't a color!!! -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
I'm getting even more confused! It looks like you have moved on now from
values like &H80000005& and system colours to standard RGB values 8210719, RGB(31,73,125) or #1F49FD Where did you get #1F49FD from, it doesn't relate to the RGB or long colour value in any way I can tell. The hex value is &H7D491F, and can be applied just like that, but the equivalent for what is sometimes known as WebHex is #1F497D (notice individual 3 hex values are reversed). FWIW webHex #1F49FD is RGB(31,73,253) All colour properties of controls accept RGB longs, so if you want to apply that (incorrect) # value you'll need to parse it with the mid function, then add "&H" coerce it to a long value. ActiveX controls can also accept the window system colour constants, like your &H80000005&. I have used the method of getting shades by graduating the L value. I was doing this from code so having an RGB value was no issue. I don't understand what you've been doing there at all but not to worry. Regards, Peter T "Paul W Smith" wrote in message ... Sorry Peter I have used the method of getting shades by graduating the L value. I was doing this from code so having an RGB value was no issue. This is another issue which is why I tried to start another thread (but failed). What I have is a heading area which is a range of cells colored with one of the theme colour. I have as certained that it is : 8210719, RGB(31,73,125) or #1F49FD I want to place a control on this header range of cells and match the control's background color to the color of the cells. Using the proprties on the control I want to set the background color but I cannot find anything that it will accept. It will not accept #1F49FD so what do I do? I know I could write something into the worksheet.activate event that colors the control because this would be doing it vua code, which I can do because I use the RGB function, but surely ther is a better way i coulod do it at design time? "Peter T" <peter_t@discussions wrote in message ... That's the constant value for vbWindowbackground, ie a system setting, typically white. I don't understand your question, you can apply that constant directly. If you want to return the user's system colour(s) it's easy enough with the GetSystemColor API, but you don't need to, at least to set the colour properties of activeX controls. Curiosity, having informed you how to go about getting a range of colour shades why didn't you follow it up. Regards, Peter T "Paul W Smith" wrote in message ... How does this help me? I need something that I can use to color a control background at run time, so it has to be in the format similar to: &H80000005& You method below turns a Long number into RGB, but I already have RGB, I need the...whatveer the definiton is for the thing that has & signs at each end. "joel" wrote in message ... MyColor = 8210719 RedShade = int(MyColor/(256*256)) GreenShade = int(MyColor/256) mod 256 BlueShade = MyColor Mod 256 RGB(RedShade,GreenShade,BlueShade) -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
As I have already tried to explain, its a constant. Namely
vbWindowBackground, used to return a system colour. Regards, Peter T "joel" wrote in message ... the number &H80000005& is a hexidecimal number. The 8 indicates the sign bit is set so you really have in bits FFFFFFFB (2's compliment). This isn't a color!!! -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
Color Variation
Joel/Peter T,
I would like to sincerely thank the pair of you for bearing with me on this. It has taken a while for the penny to drop, especially about the vbWindowsBackground variable not being an actual color. I have worked it all out now, so my thanks for your assistance. PWS "Paul W Smith" wrote in message ... Sorry Peter I have used the method of getting shades by graduating the L value. I was doing this from code so having an RGB value was no issue. This is another issue which is why I tried to start another thread (but failed). What I have is a heading area which is a range of cells colored with one of the theme colour. I have as certained that it is : 8210719, RGB(31,73,125) or #1F49FD I want to place a control on this header range of cells and match the control's background color to the color of the cells. Using the proprties on the control I want to set the background color but I cannot find anything that it will accept. It will not accept #1F49FD so what do I do? I know I could write something into the worksheet.activate event that colors the control because this would be doing it vua code, which I can do because I use the RGB function, but surely ther is a better way i coulod do it at design time? "Peter T" <peter_t@discussions wrote in message ... That's the constant value for vbWindowbackground, ie a system setting, typically white. I don't understand your question, you can apply that constant directly. If you want to return the user's system colour(s) it's easy enough with the GetSystemColor API, but you don't need to, at least to set the colour properties of activeX controls. Curiosity, having informed you how to go about getting a range of colour shades why didn't you follow it up. Regards, Peter T "Paul W Smith" wrote in message ... How does this help me? I need something that I can use to color a control background at run time, so it has to be in the format similar to: &H80000005& You method below turns a Long number into RGB, but I already have RGB, I need the...whatveer the definiton is for the thing that has & signs at each end. "joel" wrote in message ... MyColor = 8210719 RedShade = int(MyColor/(256*256)) GreenShade = int(MyColor/256) mod 256 BlueShade = MyColor Mod 256 RGB(RedShade,GreenShade,BlueShade) -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198482 http://www.thecodecage.com/forumz |
All times are GMT +1. The time now is 08:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com