Counting Coloured Cells with 2 criteria

LaurenHancy

Board Regular
Joined
Aug 5, 2010
Messages
179
Hello All!

I am quite stuck and I am sure you lovely lot will be able to solve my mystery!

So my aim is to find out which cells with a criteria of "Name" & "Date" are red. When a person is late, the cell which is a time, is colored Red.

I have names in cells A, and the date in the header going from C5:YC5. Each person has their own row and times in the cells, when they are late, I colour the cell red. is there any way to count the number of red cells per name for each month, Jan, Feb etc?

I hope you can help me :)

Thank you.

X
 
Re: HELP!!!!! Counting Coloured Cells with 2 criteria :)

Is there any way I can combine CountCellsByColour and a IF statement?


Try this:

Code:
Function [COLOR=#0000ff]CountCellsByColor[/COLOR](rData As Range, cellRefColor As Range) As Long
    Dim indRefColor As Long
    Dim cellCurrent As Range
    Dim cntRes As Long
 
    Application.Volatile
    cntRes = 0
    indRefColor = cellRefColor.Cells(1, 1).Interior.Color
    For Each cellCurrent In rData
        If indRefColor = cellCurrent.Interior.Color [COLOR=#0000ff]Or _[/COLOR]
[COLOR=#0000ff]           indRefColor = cellCurrent.DisplayFormat.Interior.Color [/COLOR]Then
            cntRes = cntRes + 1
        End If
    Next cellCurrent
 
    CountCellsByColor = cntRes
End Function
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Re: HELP!!!!! Counting Coloured Cells with 2 criteria :)

Hello,

Regarding the modified UDF in message #10 ...

forgot to mention two aspects:

1. All your Dates are supposed to be located in Row 1 ...
and the reference Month for which you need the calculation can be located anywhere

2. UDF will be working fine whenever Interior Color is changed manually ...

BUT it will not be working if the color change is produced by conditional formatting ...

Hope this clarifies
 
Upvote 0
Re: HELP!!!!! Counting Coloured Cells with 2 criteria :)

@DanteAmor
Unfortunately you cannot use DisplayFormat in a UDF
 
Upvote 0
Re: HELP!!!!! Counting Coloured Cells with 2 criteria :)

Yea & it's a right pain in the whatsits :mad:

@LaurenHancy
How many Conditional formats do you have?
If it's only one or two, what are the formulae?
 
Last edited:
Upvote 0
Re: HELP!!!!! Counting Coloured Cells with 2 criteria :)

Hello Lauren,

Just out of curiosity ... :smile:

have you finalized this issue ...???
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top