rwmill9716
Active Member
- Joined
- May 20, 2006
- Messages
- 491
- Office Version
- 2013
- Platform
- Windows
I am using the following function:
Function CountCcolor(range_data As Range, criteria As Range) As Long
Dim datax As Range
Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
CountCcolor = CountCcolor + 1
End If
Next datax
End Function
And Calling it with this statement:
=countccolor(C50:AG50,AH$26)
where C50:AG50 is a row which has cells with the same color as that found in cell AH$26
The cell in which I'm calling the function is giving me a #Name? error. I've included a figure showing the code, where it's stored and a portion of the Excel table.
Can you see anything that leading to this error in the function?
Function CountCcolor(range_data As Range, criteria As Range) As Long
Dim datax As Range
Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
CountCcolor = CountCcolor + 1
End If
Next datax
End Function
And Calling it with this statement:
=countccolor(C50:AG50,AH$26)
where C50:AG50 is a row which has cells with the same color as that found in cell AH$26
The cell in which I'm calling the function is giving me a #Name? error. I've included a figure showing the code, where it's stored and a portion of the Excel table.
Can you see anything that leading to this error in the function?