You should also realise that even when you set a cell to an RGB value, Excel
will match this to the nearest Colorindex, and use that. So it may not be
exactly the colour you wanted.
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Chip Pearson" wrote in message
...
Avner,
A function called from a worksheet cell cannot change anything in
the Excel environment, including the colors of cells. All it can
do is return a value. Your code doesn't work because it attempts
to change something that is off limits to code called from a
cell.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Avner Mediouni" wrote in message
...
I would like to write a function that will color the interior
of a cell
according to RGB values.
This is my code:
Function InteriorColor(ByVal R as Integer, ByVal G as Integer,
ByVal B as
Integer)
ActiveCell.Interior.Color = RGB(R, G, B)
End Function
This simple code refuse to work when I call it from a
worksheet, although it
works well when activates him from another subroutine.
What is wrong ?!!
Thanks for the help
Avner
R&D Physicist
email: