Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

COLOR INDEX UPDATING & FOR CONDITIONAL FORMATTING!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FARAZ QURESHI - 08 Dec 2007 22:11 GMT
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 - 08 Dec 2007 22:33 GMT
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.

> Hi friends,
>
[quoted text clipped - 15 lines]
>
> FARAZ

Signature

Dave Peterson

Joel - 08 Dec 2007 22:40 GMT
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 .

> Hi friends,
>
[quoted text clipped - 15 lines]
>
> FARAZ
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.