- Joined
- Jul 31, 2015
- Messages
- 231
- Reaction score
- 33
Someone gave me a great routine to count the colour of cells in a range.
But - that doesn't work if the colour is applied with conditional formatting. And I can't find a routine which does work for that. I thought it would be "DisplayFormat.Interior" but that doesn't work (for me).
Does anyone have any idea how I can get the colour count if the colour is applied with conditional formatting?
Thanks for any advice
Alan
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
But - that doesn't work if the colour is applied with conditional formatting. And I can't find a routine which does work for that. I thought it would be "DisplayFormat.Interior" but that doesn't work (for me).
Does anyone have any idea how I can get the colour count if the colour is applied with conditional formatting?
Thanks for any advice
Alan