I received the coding for the function below from a peer. I copy/pasted this code into Module1 in my personal.xlsb file within the VB Editor. When I try to recall the function, the cell populates with #NAME? I've tried closing & re-opening excel and that did not fix it. Any help that you can provide is greatly appreciated.
I typed: =COUNTCOLOR(H3,D3:E22)
and received: #NAME?
Function CountColor(rColor As Range, rSumRange As Range)
Dim rCell As Range
Dim iCol As Integer
Dim vResult
iCol = rColor.Interior.ColorIndex
For Each rCell In rSumRange
If rCell.Interior.ColorIndex = iCol Then
vResult = vResult + 1
End If
Next rCell
CountColor = vResult
End Function
I typed: =COUNTCOLOR(H3,D3:E22)
and received: #NAME?
Function CountColor(rColor As Range, rSumRange As Range)
Dim rCell As Range
Dim iCol As Integer
Dim vResult
iCol = rColor.Interior.ColorIndex
For Each rCell In rSumRange
If rCell.Interior.ColorIndex = iCol Then
vResult = vResult + 1
End If
Next rCell
CountColor = vResult
End Function