[ad_1]
I am trying to count the cells of a specific color in a row. I have seen the other questions regarding this topic and have also seen all the other helping pages on the web but nothing seems to work for me.
This is my function code which I coped from another answer that was appearently working for the guy asking:
Function ColorCount(rColor As Range, rRange As Range)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = r.Color.Interior.ColorIndex
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
ColorCount = vResult
End Function
My test sheet is easy, as it gets. In A3, I want to write the formula =ColorCount(A3, A3:C3)
and in A3 I used the Fill Color
tool from Excel to fill the cell with orange. The code was added in the VBA section I accessed with Alt+F11, once directly in the sheet-code fragment and once as a module. I saved the file as an .xlsm
-file.
Excel is just saying There's a problem with this formula.
, so not much to gain in information here sadly
[ad_2]