Excel VBA ? Counting red coloured cells under headings and extracting them against date / month

Jase Alexander
Jase Alexander used Ask the Experts™
Hi Experts

Hope you can help although I’m not sure if what I’m looking for is possible

I had some excellent assistance with this from the experts and submitted this report with a basic summary however what is required is a little more challenging

I believed using the Colorfunction () online VBA module would solve my issue of counting the coloured cells and it has for the transport summary however what is required is to devise a monthly breakdown per sheet.

This requires some modification to the code to be able to count the number of red cells against each heading (or Columns F to M) but also against the corresponding dates so it provides a count, per month, of the red cells, per heading, to the right of the main sheet

I’ve provided an example on the Air tab, I have manually entered the data in the summary to the right to show the desired results

Is this possible? I’ve tried consolidating some examples I discovered on line using the SUMPRODUCT function, but I haven’t found a suitable solution

Your suggestions would be very welcome
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Here are 2 ways to do it.

On sheet Air the count is done with a VBA function, checking the dates and colors.
The values in T1:AE1 are changed to dates, so the dates in column D can be compared to that.
Then formatted to show Jan, Feb etc.
The year is in S1, with the color to count.

On sheet Air (2) the count is with a SUMPRODUCT function.
The values to count are in columns F:M, where 1 is green, and 2 is red.
The color in the cells are done by conditional formatting, both cell and text, so the value is not visible in the cell, see the formula line.
I think typing 1 or 2 is easier than changing the color of the cell,
And then the calculation is with standard formulas.
Director of Technology Development, IPM
See the attached with the 2 added macros.
On Sheet1 you simply add the following macro for each monthly total:
=SumMonthlyTotal($A$2, "colorColumn", "D", month)

$A$2 = cell containing the color you are looking to count
"colorColumn" = the column you are searching (e.g. for Nav = "F", for Ricardo = "G", etc.)
"D" = the column containing the date field
month  = only dates falling in this month will be summed in this cell
MonthSum1.jpg  monthSum2.jpgCountColoredCells.xlsm
Jase AlexanderCompliance Manager


HI Both

Thank you so much for your response to this I cant tell you how much I appreciate your help

I learn so much from you guys


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial