On Nov 16, 12:46 pm, Christine <Christ...@discussions.microsoft.com>
wrote:
> After reading quite a few posts I see there is no way to count the number of
> color entries in a worksheet - and have the numbers update "live" and
> automatically as coloring changes. This is a problem for my requirements, in
> addition to some other functionality that my worksheet requires. Hopefully
> someone can take this on!!
>
> What I'm trying to do is to highlight overdue tasks, tasks that are due
> within the next seven (preferably working) days, tasks due in 2 weeks time,
> and show a summary of these (and thus progress against the project) in a
> Red/Green/Yellow table.
>
> The worksheet has a number of cells where the user will enter a dates for
> when a task is due and when the task is complete. These date cells have the
> "CalcProgress" style applied to them. I want to highlight the due dates in
> green and red, and automatically total the number of these coloured entries
> in the worksheet and update the totals as they change.
>
> For example:
>
> Total Red Cells: nnn
> Total Green Cells: nnn
> Total Yellow Cells: nnn
>
> If the due date is <=Today() , the font should be red, bold
>
> If the due date is < =TODAY()+7, the font should be yellow bold
>
> If the due date is < =TODAY()+14, the font should be green (black, not bold)
>
> HOWEVER!! When the user enters a date in the "Date Complete" cell for the
> item, due date colouring should revert to plain text (normal). As the "Date
> Complete" cells are filled, the total count of red, green and yellow cells
> would decrease accordingly.
>
> Hope this is understandable - and possible!!
>
> Any assistance will be really, really appreciated!
For the automatic colouring, you're probably going to need Conditional
Formatting (on the Format menu). I don't know if this can be attached
to a Style or not... I suggest you use the "Formula Is" option rather
than "Cell Value Is".
While it's fairly easy normally to establish the colour (background or
font) of a cell via a smallish VBA function, it's tricker by far when
the colouring is applied via conditional format. Ticky enough that I
recommend you avoid it, if only because I don't know right now how best
to go about it. (It's likely to involve examining the formatting
conditions in code, working out what they think about things and what
the result would be - as I say, tricky).
Fortunately, we don't have to count cells by colour, we can just count
the numbers that meet our formatting conditions. There's COUNTIF(),
which I don't like much (can be slow and I hate putting formula-type
stuff in quoted text) and then there are array formulae, which I
perhaps like too much...
Say your due dates are in cells B2:B99, then to count the dates that
are within 7 days from now, enter the following:
=SUM(IF(B2:B99-TODAY()<7,1,0))
....and enter it into the spreadsheet using Control+Shift+Enter (hold
down Control and Shift before pressing Enter) which creates an array
formula. The yellow and green counts are left as an exercise for the
student...
HTH,
Mike