L
LordHog
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
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