IF Function Including Count Colour

I was able to count cells by their background color by the following:

Function CountColour(rng As Range, clr As Range)
Dim c As Range
For Each c In rng
    If c.Interior.ColorIndex = clr.Interior.ColorIndex Then
        CountColour = CountColour + 1
    End If
Next
End Function

However, I need to add an IF function to this module… Any suggestions????

I am not very proficient in Excel and simply adding the module was a big win, but I’m not quite there yet… :/

PLEASE HELP ME!

3 thoughts on “IF Function Including Count Colour

  1. Excel Geek

    What is the IF Function that you want to include? It could either be added to the VBA code or incorporated into the Formula that you enter in a cell.

  2. souk3650

    The IF function is needed to add a parameter based on dates when it sums the colored cells. I discovered last night that in Excel one cannot add a function to a cell which is not created by a condition. The cells that contain color are data that is input from another program which is linked to this spreadsheet. Or am I wrong???

    The only resolution that I can come up with is to add conditional formulas to the cells which contain color. This adds another step to an already conveluted spreadsheet…

  3. Excel Geek

    OK, so you want to sum the coloured cells based on a date criteria…? Would that be correct? If so, is it matching dates, less than, greater than…?

Leave a Reply

Your email address will not be published. Required fields are marked *