Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a range of cells with different RGB values e.g.
Column 1 RGB(0,0,0) RGB(0,255,0) I am reading these values and in my macro and setting the color of a range of cells using the following statement. rangec.Interior.Color = Worksheets("output").Cells(mrgb, 13).Value I get an error message stating that VB is unable to set the color property however when I hard code the value as below, the code works fine. rangec.Interior.Color = RGB(0,255,0) I did not want to hard code it because of the obvious reason ( for users to change/add colours in the future) I tries capturing the cell value in a variable ( tried string, variant) and nothing worked. Also I tried vbRed; vbBlue etc instead of the RGB( ) function and still the same behaviour. Wondering if anyone has any tips? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
VBA cannot interpret your text "RGB(0,0,0)". You could put R, G, and B into
adjacent cells and use this: With Worksheets("output") rangec.Interior.Color = RGB(.cells(mrgb,13), .cells(mrgb,14), ..cells(mrgb,15)) End With - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "haileybury" wrote in message ... I have a range of cells with different RGB values e.g. Column 1 RGB(0,0,0) RGB(0,255,0) I am reading these values and in my macro and setting the color of a range of cells using the following statement. rangec.Interior.Color = Worksheets("output").Cells(mrgb, 13).Value I get an error message stating that VB is unable to set the color property however when I hard code the value as below, the code works fine. rangec.Interior.Color = RGB(0,255,0) I did not want to hard code it because of the obvious reason ( for users to change/add colours in the future) I tries capturing the cell value in a variable ( tried string, variant) and nothing worked. Also I tried vbRed; vbBlue etc instead of the RGB( ) function and still the same behaviour. Wondering if anyone has any tips? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Changing cell colors from a function command | Excel Worksheet Functions | |||
Dynamically setting CELL COLORS based on TWO OTHER cell values | Excel Discussion (Misc queries) | |||
Is there a function like Vlookup that works with cell colors? | Excel Worksheet Functions | |||
MY 2003 Excel does not show cell colors. Solution? Setting? | Excel Discussion (Misc queries) | |||
Using if function with cell fill colors | Excel Programming |