Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have written the following code to change cell font colour to RGB values
222, 155, 55 Sub CellColourChange() ' Set the font colour of cell G18 to RGB scale from answers in questionnaire. Range("G18").Select Selection.Font.Color = RGB(222, 155, 55) End Sub However, I would really like to make this code more advanced, getting the rgb values from cells (e.g. I18, j18, k18). I tried using Font.Color = RGB("I18", "j18", "k18") instead of the values I used in the first version. This clearly does not work. Can anyone tell me how to do this? I'd appreciate the help a lot. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can do something like
Selection.Font.Color = RGB(Range("I18").Value, Range("J18").Value, Range("K18").Value) Note, though that you may not get the exact color you want. Excel is limited to 56 colors. Those can be any 56 colors you want, but you still get only 56. If you attempt to use a color that is not on Excel's pallet, it will choose the closest color on the pallet to what you specify. Since the idea of a "closest" color is rather subjective you may not get the right color. You could modify the pallet to include your new color: Dim C As Long C = RGB(Range("I18").Value, Range("J18").Value, Range("K18").Value) ThisWorkbook.Colors(56) = C Selection.Font.ColorIndex = 56 -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting www.cpearson.com (email on the web site) "greencecil" wrote in message ... I have written the following code to change cell font colour to RGB values 222, 155, 55 Sub CellColourChange() ' Set the font colour of cell G18 to RGB scale from answers in questionnaire. Range("G18").Select Selection.Font.Color = RGB(222, 155, 55) End Sub However, I would really like to make this code more advanced, getting the rgb values from cells (e.g. I18, j18, k18). I tried using Font.Color = RGB("I18", "j18", "k18") instead of the values I used in the first version. This clearly does not work. Can anyone tell me how to do this? I'd appreciate the help a lot. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding codes based on a font color | Excel Discussion (Misc queries) | |||
sumif - I wish to add cells based on the font/fill colour | Excel Worksheet Functions | |||
Advanced Conditional Formatting Help Required - Change cell colour based on values of other cells | Excel Programming | |||
Change font and background color of several cells based on result of a formula | Excel Discussion (Misc queries) | |||
Change the colour of a bunch of cells, based on one cell. | Excel Programming |