I am trying to count the number of cells in a specific column that are filled with a specific color, as there can be multiple colors within one column. These cells can be empty or filled with text, and the excel guides I've found online aren't helping much as they can only count one or the other. I found a VBA guide which suggested this code:
Function ColorCount(ColorCell As Range, DataRange As Range)
Dim Data_Range As Range
Dim Cell_Color As Long
Cell_Color = ColorCell.Interior.ColorIndex
For Each Data_Range In DataRange
If Data_Range.Interior.ColorIndex = Cell_Color Then
ColorCount = ColorCount + 1
End If
Next Data_Range
End Function
However, when I input this code and ran the =ColorCount function, every cell with any type of color was counted. Is there something I am doing wrong here? The specific function syntax I was told to follow is =ColorCount("cell with specific color as example","range of cells to count").