I cant take the credit for this, but I don’t remember where it came from
Once you have the code below in a module, you can use this formula:
=countcolor(A1:A99,D2)
Where A1:A99 is the range you want to count and D2 has the background format that you want to count.
Note this will not update automatically if you change color in D2 or put more formats in your range, you have to clickin the cell with the formula,click in the formula bar and hit enter to make it recalculate
Function CountColor(Rng As Range, RngColor As Range) As Integer
Dim Cll As Range
Dim Clr As Long
Clr = RngColor.Range("A1").Interior.Color
For Each Cll In Rng
If Cll.Interior.Color = Clr Then
CountColor = CountColor + 1
End If
Next Cll
End Function