Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
Note: I asked this question, originally, in the general group, but advised to move the question to this group. Sorry for the cross- posting. I am trying to write a macro/function in Excel 2007 that will set a cell's color based upon RGB values passed in as arguments. So the function declaration will look like: Public Function SetCellColor(HEX2DEC(A1), HEX2DEC(A2), HEX2DEC(A3) ) ActiveCell.Cell.Interior.Color = RGB(100, 100, 100) End Function Then for a particular cell, say C12, I would set the cell to =SetCellColor( HEX2DEC(C1), HEX2DEC(C2), HEX2DEC(C3) ) Obviously, this doesn't work as the ActiveCell set's the active cell's color and not the cell that has the =SetCellColor set for it. Also, I get an error 1004 when I run this code. Does anyone know how I might set accomplish this task. Oddly, if I use the following instead, it will actually set the active cell's border without throwing an error. ActiveCell.Cells.Borders.Color = RGB(r, g, b) I have no idea why this one works, but not the other one. Any help is greatly appreciated. Mark |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula to populate data in a cell based on another cell's color | Excel Discussion (Misc queries) | |||
UserForm - Setting focus to a CommandButton based on a Cell's contents | Excel Programming | |||
Have row color change to one of 8 different colors based on one cell's value (I, O, C, T, L, E, X, A) | Excel Discussion (Misc queries) | |||
Change a cell's color based on return value of a formula | Excel Programming | |||
Setting cell background color based on value | Excel Programming |