Set cell color with VBA results in "#VALUE!"
Well, I already tried that once, and just redid it to verify it, but
unfortuantely using ColorIndex instead of Color does not change anything. :-(
"Mike H" wrote:
Try these
MsgBox Cells(1, 1).Interior.ColorIndex
Cells(1, 1).Interior.ColorIndex = 10
Mike
"Christian Schratter" wrote:
Hello
I made a function in a new module with a function which looks like this:
Public Function testColor()
MsgBox Cells(1, 1).Interior.Color 'does work - displays e.g. 255
Cells(1, 1).Interior.Color = 10 'does NOT work - displays "#VALUE!"
in the calling cell
End Function
This function gets called in a cell ("=testColor()").
The target would be to change the color of a cell with this VBA function.
Sadly setting the color does not work, while I can perfectly read the
color-code.
Where's the mistake here? I'm using Excel 2007.
|