Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default color function

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
add fill color or font color to if function MEDaniel Excel Worksheet Functions 7 November 9th 08 07:09 AM
Color formula function darrod64 Excel Worksheet Functions 2 August 25th 06 01:42 AM
IF function for cell color Clark Excel Worksheet Functions 1 May 22nd 06 09:43 PM
How to put color on if function aldrain Excel Worksheet Functions 5 August 8th 05 08:12 AM
cell color within a function billQ Excel Programming 3 July 18th 03 07:36 PM


All times are GMT +1. The time now is 03:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"