PC Review


Reply
Thread Tools Rate Thread

COLOR INDEX UPDATING & FOR CONDITIONAL FORMATTING!

 
 
FARAZ QURESHI
Guest
Posts: n/a
 
      8th Dec 2007
Hi friends,

One of the reputable experts advised me to use the following code to return
the color index of a cell:

Public Function Color(ByVal rgeCell As Range) As Integer
Color = rgeCell.Interior.ColorIndex
End Function

The problem is that reply of such a function upon "change" of the colour of
the target cell doesn't update and I have to manually use F2 and then ENTER
again so as to update the value or copy and paste the same formula.

Furthermore any professional advice to have have such a formula working for
CONDTIONAL FORMATTING shall highly obliged.

Thanx in advance to all you pals.

FARAZ
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      8th Dec 2007
First, this function won't update when formatting is changed. Formatting
doesn't cause excel to recalc.

You could make the function volatile:
Public Function Color(ByVal rgeCell As Range) As Integer
application.volatile
Color = rgeCell.Interior.ColorIndex
End Function

But this still could be one calculation behind--leading to incorrect results.

Second, this function returns the colorindex of the cell when you apply the
formatting--not the color from conditional formatting.

If you want to try to return the color based on conditional formatting, you
could review the code from Chip Pearson's site:

http://cpearson.com/excel/CFColors.htm

I think it's far from trivial. You may want to use another cell that mimics the
same conditions, but returns a number. It may be lots easier.



FARAZ QURESHI wrote:
>
> Hi friends,
>
> One of the reputable experts advised me to use the following code to return
> the color index of a cell:
>
> Public Function Color(ByVal rgeCell As Range) As Integer
> Color = rgeCell.Interior.ColorIndex
> End Function
>
> The problem is that reply of such a function upon "change" of the colour of
> the target cell doesn't update and I have to manually use F2 and then ENTER
> again so as to update the value or copy and paste the same formula.
>
> Furthermore any professional advice to have have such a formula working for
> CONDTIONAL FORMATTING shall highly obliged.
>
> Thanx in advance to all you pals.
>
> FARAZ


--

Dave Peterson
 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      8th Dec 2007
Excel doesn't recognize a change of color as an Event. Events are what
causes the spreadsheet to get updated and causes macros to run. Therefore,
colors cannot cause any updates of calculations nor can it cause a macro to
run .

"FARAZ QURESHI" wrote:

> Hi friends,
>
> One of the reputable experts advised me to use the following code to return
> the color index of a cell:
>
> Public Function Color(ByVal rgeCell As Range) As Integer
> Color = rgeCell.Interior.ColorIndex
> End Function
>
> The problem is that reply of such a function upon "change" of the colour of
> the target cell doesn't update and I have to manually use F2 and then ENTER
> again so as to update the value or copy and paste the same formula.
>
> Furthermore any professional advice to have have such a formula working for
> CONDTIONAL FORMATTING shall highly obliged.
>
> Thanx in advance to all you pals.
>
> FARAZ

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Font Color Conditional Formatting/Color Scaling Ryan Microsoft Excel Worksheet Functions 0 4th Mar 2010 06:03 PM
How to know get the color index for the conditional formatting? =?Utf-8?B?bHV2Z3JlZW4=?= Microsoft Excel Programming 3 20th Jul 2007 09:50 PM
Color index & conditional format =?Utf-8?B?SGFybGV5?= Microsoft Excel Programming 1 16th Nov 2006 01:11 PM
Conditional color formatting entries have wild color. =?Utf-8?B?Sm9obiBHZXllcg==?= Microsoft Excel Misc 0 24th Feb 2006 06:11 PM
Conditional Formatted Cell Color Index =?Utf-8?B?TURSNTMwMA==?= Microsoft Excel Programming 5 27th Jan 2005 09:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:13 PM.