ColorCellsBy Colour plus 2 more matcing criteria HELP, SO STUCK!!! :)

LaurenHancy

Board Regular
Joined
Aug 5, 2010
Messages
179
Hi All,

Hope you are having a great Tuesday. I desperately need your help.

I need to count the number of red cells (data range in colour C2:JC2) per person depending on the the following criteria:

Name = Collum A
By Month, Jan, Feb etc = Row C1:YC1 (MM/DD/YYYY)
"Lates" = Collum B

B34 is the *red* cell referance

I have the following formula already but I cant seem to add the other criteria into this formula. It works but I have to select which cells to count for each name and month. There are many names to contend with.

=CountCellsByColor('Daily Call KPI''s'!$C$2:$JC$2,$B34)


ABCDEFG
101-Jan02-Jan03-Jan04-Jan05-Jan
2Davidavailibility*Red**Green**Green**Green**Green*
3Lates
*Green**Green**Green**Red*
4Kellyavailibility*Green**Red**Green**Green**Green*
5
Lates
*Green**Red**Green*
6Janeavailibility*Green**Green**Green**Green**Green*
7Lates
*Green**Green**Green**Green*

<tbody>
</tbody>

Thank you for you help.

L xx
 
Last edited:
Great ...

For the Monthly Recap you want to create ... in which cells are you going to type : Jan Feb Mar etc ... ???
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Since you seem to have 50 rows of data ...

made the assumption your recap would be in Row 56 ...

Below is your revised UDF

Code:
Function CountCellsByInteriorColorWithConditions(rData As Range, cellRefColor As Range, sMonth As Range) As Long
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'                               HOW TO USE THIS FUNCTION
' =CountCellsByInteriorColorWithConditions($C2:$JC2,$B$34,C$56)
' $C2:$JC2  the reference row
' $B$34 the cell which contains your red color
' C$56 the cell which contains the month...i.e Jan or Feb or Mar ...
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  
  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
          ' Added Month Condition '''''''''''''''''''''''''''''''''''''''''''''''''''''
          If indRefColor = cellCurrent.Interior.Color Then
              If Month(Cells(1, cellCurrent.Column)) = Month(DateValue("01-" & sMonth.Value & "-2019")) Then cntRes = cntRes + 1
          End If
      Next cellCurrent
 
    CountCellsByInteriorColorWithConditions = cntRes
End Function

Hope this will help
 
Last edited:
Upvote 0
The months recap will be in a new sheet, E6:O6, these will be Jan, Feb, Mar etc

Taken from this data C1:ND1. date range from 01/01/19 to 31/12/19 like the below format.

ABCDEFG
101-Jan02-Jan03-Jan04-Jan05-Jan
2Davidavailibility*Red**Green**Green**Green**Green*
3Lates
*Green**Green**Green**Red*
4Kellyavailibility*Green**Red**Green**Green**Green*
5Lates
*Green**Green**Red**Green*
6Janeavailibility*Green**Green**Green**Green**Green*
7Lates
*Green**Green**Green*

<tbody>
</tbody>

I hope I am making sense, so sorry If I'm being difficult here :(
 
Last edited:
Upvote 0
Ive used your formula but it is just pulling through 0. This is what I have used:

=IFERROR(CountCellsByInteriorColorWithConditions('Daily Call KPI''s'!$C$7:$JC$7,$B20,E$6),"")

C7:JC7 - Cells with red and green cells
B20 - Red reference cell
E6 - Month reference
 
Upvote 0
Thanks for the infos ...

Talking about the Data ...

Since your are using an example with Row 7 ... Can you at least confirm all the Dates are located in Row 1 ... ???

And regarding the Color .. it is located on the same sheet as the Months with your Recaps ... right ..?
 
Last edited:
Upvote 0
So the dates listed in sheet 1 (Daily Call KPI's) from 01/01/19 to 31/12/19 etc (C5:JC5)

Colour is located on the same sheet under each person's row:

James = (C7:JC7)
Tanya = (C10:JC10)
Katie = (C13:JC13)
etc

Sheet 2 (Monthly KPI stats) is where I am recapping the data into months. The months heading is Jan D6, Feb E6, etc,

Colour referance has now changed to F6 (Red). Just to make it even more confusing for you!!! :)
 
Upvote 0
Have you tested :

=CountCellsByInteriorColorWithConditions('Daily Call KPI''s'!$C$2:$JC$2,$F6,D$6)
 
Upvote 0

Forum statistics

Threads
1,214,881
Messages
6,122,074
Members
449,064
Latest member
MattDRT

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