I want to count number of cells with two criteria : their color and their value.
I select the range, then the color, then the value of the cell.
I made this code in vba but it doesn't work.
Function CountCcolor(range_data As Range, criteria As Range, cellvalue 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 And datax.value = cellvalue.value Then
CountCcolor = CountCcolor + 1
End If
Next datax
End Function
I think that the problem is in my cellvalue.value I don't know how I can access a selected cell value.
Thank you for your help