I am using the following function to count cells by color, but comes up with a #name? error.
In Cell AH5 I have the function =CountByColor(AF5, tblIndex). Where cell AF5 contains the cell with the color background to count, and tblIndex is the named range K4:AD66. What am I doing incorrectly?Function CountByColor(CellColor As Range, CountRange As Range) Application.Volatile Dim ICol As Integer Dim TCell As Range ICol = CellColor.Interior.ColorIndex For Each TCell In CountRange If ICol = TCell.Interior.ColorIndex Then CountByColor = CountByColor + 1 End If Next TCell End Function