How can I count the colour of cells with conditional formatting


  1. Posts : 7
    Windows 10
       #1

    How can I count the colour of cells with conditional formatting


    Someone gave me a great routine to count the colour of cells in a range.
    Code:
    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
    This is for the latest Excel from Office 365. Running on WIndows 10 - latest updates.
    Alan
      My Computer


  2. Posts : 781
    Windows 10
       #2

    Hi, @alan sh.

    Have you seen this? It may help you:

    How to Count COLORED Cells in Excel [Step-by-Step Guide + VIDEO]

    -James
      My Computer


  3. Posts : 7
    Windows 10
    Thread Starter
       #3

    Yes, but that doesn't work when the cells are coloured by a conditional format statement.

    thanks

    Alan
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 20:44.
Find Us




Windows 10 Forums