1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
Function CountColor(rColorRange As Range, rColorIndex As Range) As Long Dim rCell As Range 'range for loop. Dim lColor As Long 'Index of the cells color we want to count. Dim lColorCount As Long 'Counter lColorCount = 0 'Initialize counter lColor = rColorIndex.Interior.ColorIndex 'Set color to count 'Loop through each cell in the range For Each rCell In rColorRange If rCell.Interior.ColorIndex = lColor Then lColorCount = lColorCount + 1 Next rCell 'Return count to function CountColor = lColorCount End Function