Counting Cells with ColorFunction per month

highlander2536

New Member
Joined
Feb 7, 2012
Messages
4
Hi Have a sheet that counts the total number of cells in a column with specific colours
=ColorFunction(Closed!$B$1,Closed!$G$7:$G$9071,FALSE)

Each Cell has a date in it. I am able to count the total number of cells in used in any month by the date entered
=SUMPRODUCT(--(MONTH(Closed!D7:D2071)=1),(--(YEAR(Closed!D7:D2071)=2012)))

I now need to be able to combine the 2 by counting the total number of cells that are coloured RED for example in a specified month. Any suggestions
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
The ColorFunction is not native to Excel.
Is an UDF -User Define Formula created by ..you?
Can you provide the VBA code?
 
Upvote 0
VBA

Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult

lCol = rColor.Interior.ColorIndex

If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If

ColorFunction = vResult
End Function

This was taken from another website which works perfectly for my needs for counting total colours but still need to be able to count colours by month
 
Upvote 0

Forum statistics

Threads
1,216,759
Messages
6,132,549
Members
449,735
Latest member
Gary_M

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