View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pete_UK Pete_UK is offline
external usenet poster
 
Posts: 8,856
Default need to compare dates and count results

Heather,

have a look at this link:

http://www.cpearson.com/excel/colors.htm

Chip Pearson shows how you can return the colour of a cell with a user-
defined function, and also explains how to count coloured cells - just
what you are after.

Hope this helps.

Pete

On Mar 9, 7:44 pm, "Heather" wrote:
I have two columns of dates. The first column is the date the event
actually occurred or is 0 if nothing has been done yet. The second column
is the target date by which the event should happen, the deadline.

I was able to create conditional formatting for the first column. It turns
each date green if the task was complete or if the due date was more than 24
hours from today. The date turns yellow if it is incomplete and the due
date is 24 hours from today. The date turns red if it's incomplete, and
it's target date is today or has passed.

I would now like to be able to add up how many dates are green, how many are
yellow, and how many are red. Can I count cells based on their format color?
I couldn't figure out a way. So I tried creating a countable column, but I
haven't been able to figure out how to combine the three test conditions
into a single counting function or a single function to create a new row of
data I could count like L1.

Here are my 3 formulas, and what I would like the 3rd column to look like if
I can't count the format color changes in J1 directly.
Green =OR(K2 Today()+1, AND(K2<(TODAY()+1),OR(J2 = K2,J2<0)))
Yellow =AND(K2=TODAY()+1,J2 = 0)
Red =AND(K2<=TODAY(),J2 = 0)

J K

Site inspection Site inspection (target)
1/12/2007 1/15/2007
3/08/2007 3/08/2007
0 3/10/2007
0 2/28/2007

L
Compare result
G
G
Y
R
xposted to microsoft.public.excel, but this board seemed more active