Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You have the low down as to why a udf cannot directly
apply formats etc. However I find it is possible for a udf to trigger a normal macro (to do the formatting) by using SendKeys to send an already created keyboard shortcut to the macro. You also need some global variables to store the arguments of the function for use by the macro. Also as explained by others, an applied format will be one of the existing 56 palette colours, the nearest matched. If you want to apply your own colour, customize a colorindex with the macro, then apply same colorindex as the format. Add an extra argument for cIndex: Activeworkbook.colors(cIndex) = value The udf / sendkeys / macro method is far from satisfactory for general use. At the very least may need other things to avoid problems, depending on the context. However I did develop an instant palette customizer based on this approach that seems to work. Regards, Peter -----Original 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: . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
add fill color or font color to if function | Excel Worksheet Functions | |||
Color formula function | Excel Worksheet Functions | |||
IF function for cell color | Excel Worksheet Functions | |||
How to put color on if function | Excel Worksheet Functions | |||
cell color within a function | Excel Programming |