LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Setting a cell's color based upon RGB values

Hello,

Note: I asked this question, originally, in the general group, but
advised to move the question to this group. Sorry for the cross-
posting.

I am trying to write a macro/function in Excel 2007 that will set a
cell's color based upon RGB values passed in as arguments. So the
function declaration will look like:

Public Function SetCellColor(HEX2DEC(A1), HEX2DEC(A2), HEX2DEC(A3) )

ActiveCell.Cell.Interior.Color = RGB(100, 100, 100)

End Function

Then for a particular cell, say C12, I would set the cell to

=SetCellColor( HEX2DEC(C1), HEX2DEC(C2), HEX2DEC(C3) )

Obviously, this doesn't work as the ActiveCell set's the active cell's
color and not the cell that has the =SetCellColor set for it. Also, I
get an error 1004 when I run this code.

Does anyone know how I might set accomplish this task. Oddly, if I
use the following instead, it will actually set the active cell's
border without throwing an error.

ActiveCell.Cells.Borders.Color = RGB(r, g, b)

I have no idea why this one works, but not the other one. Any help is
greatly appreciated.

Mark
 
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
Formula to populate data in a cell based on another cell's color Cassie Excel Discussion (Misc queries) 1 February 6th 09 04:12 PM
UserForm - Setting focus to a CommandButton based on a Cell's contents PCLIVE Excel Programming 2 January 31st 07 06:02 PM
Have row color change to one of 8 different colors based on one cell's value (I, O, C, T, L, E, X, A) Mel Excel Discussion (Misc queries) 8 October 6th 06 03:16 PM
Change a cell's color based on return value of a formula Gee-off Excel Programming 4 December 4th 05 02:02 PM
Setting cell background color based on value Erik[_5_] Excel Programming 3 February 25th 04 10:56 PM


All times are GMT +1. The time now is 11:58 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"