

July 16, 2010

Hi,
This tutorial covers counting coloured cells: https://www.myonlinetraininghu.....ored-cells
Mynda


Trusted Members
Moderators

November 1, 2018

No, but you've commented out the code in your workbook and merged two lines together. It should look like this:
Function CountCcolor(range_data As Range, criteria As Range) As Long
Application.Volatile True
Dim datax As Range
Dim xcolor As Longxcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
CountCcolor = CountCcolor + 1
End If
Next datax
End Function
with no apostrophes at the start of each line. Note that you need the function to be volatile to have any chance of it calculating correctly, but note also that changing a cell colour does not trigger a recalculation, so this approach is, in my opinion, fundamentally flawed anyway.
1 Guest(s)
