I found the following code online to be able to count how many cells are in a certain color, however its only returning #NAME
So I'm using this VBA -
Function GetColorCount(CountRange As Range, CountColor As Range, TheValue As Variant)
Dim CountColorValue As Long
Dim TotalCount As Long
Dim rCell As Range
CountColorValue = CountColor.Interior.Color
Set rCell = CountRange
For Each rCell In CountRange
If rCell.Interior.Color = CountColorValue And rCell.Value = TheValue Then
TotalCount = TotalCount + 1
End If
Next rCell
GetColorCount = TotalCount
End Function
And then in the cell I want the sum total in, I have =GetColorCount($B$2:$B$25,L1)
Where the range I want to total is B2:B25 and L1 has the background color I want to count
This is not working
So I'm using this VBA -
Function GetColorCount(CountRange As Range, CountColor As Range, TheValue As Variant)
Dim CountColorValue As Long
Dim TotalCount As Long
Dim rCell As Range
CountColorValue = CountColor.Interior.Color
Set rCell = CountRange
For Each rCell In CountRange
If rCell.Interior.Color = CountColorValue And rCell.Value = TheValue Then
TotalCount = TotalCount + 1
End If
Next rCell
GetColorCount = TotalCount
End Function
And then in the cell I want the sum total in, I have =GetColorCount($B$2:$B$25,L1)
Where the range I want to total is B2:B25 and L1 has the background color I want to count
This is not working