danjw_98 said:I tried to use the "=CountIfColor(a1:a10,3) to count the number of red filled cells and it doesn't seem to work - it shows "#name?" in the cell that I have this in.
any suggestions?
Sub CountColours()
Dim q1 As Range, q2 As Range, MyColour, c, I As Integer
Set q1 = Application.InputBox("Click on a cell that has the colour you want to count", _
"select Colour", , , , , , 8)
MyColour = q1.Interior.ColorIndex
Set q2 = Application.InputBox("Select the range to look in", _
"Range to count colour", , , , , , 8)
I = 0
For Each c In q2
If c.Interior.ColorIndex = MyColour Then
I = I + 1
End If
Next c
MsgBox "There are " & I & " cells in the range that match your colour"
End Sub