Thread: color function
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default color function

Hi
a function invoked from a worksheet cell can ONLY return values but is
not allowed to change the Excel environment (e.g. formats or other
cells). So no chance to achieve this with a formula entered in a cell.

--
Regards
Frank Kabel
Frankfurt, Germany


Avner Mediouni wrote:
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: