+ Reply to Thread
Results 1 to 10 of 10

Count coloured cells with conditional formatting

  1. #1
    Registered User
    Join Date
    10-27-2020
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    51

    Count coloured cells with conditional formatting

    Hi there,

    I want Excel to count coloured cells for me. I've got this code but it seems it doesn't work when the colour is changed due to conditional formatting.
    Additionally, it doesn't refresh when the colours are getting updated.

    Please Login or Register  to view this content.
    Any help is greatly appreciated.

    Cheers,
    Kapi
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Count coloured cells with conditional formatting


    Hi,

    try with DisplayFormat but on my side under old Excel versions can't work within such function …

  3. #3
    Registered User
    Join Date
    10-27-2020
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Count coloured cells with conditional formatting

    Hi mate,

    Could you please provide some further details on how this could be done?

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Count coloured cells with conditional formatting


    Using DisplayFormat property like you can see in VBA help works on my side in a Sub procedure
    but not with your function so the VBA procedure should be launched via a button or via a Worksheet event …

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Count coloured cells with conditional formatting


    If that can't work neither on your side via DisplayFormat then
    via your function do not compare the colors but the values obviously …
    Edit : In fact VBA seems useless to compare values just using directly cells formulas !
    Last edited by Marc L; 08-25-2023 at 08:27 PM.

  6. #6
    Registered User
    Join Date
    10-27-2020
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Count coloured cells with conditional formatting

    I'm sorry but I'm still confused.
    Could someone clarify?

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: Count coloured cells with conditional formatting

    As the fill colors are produced by conditional formatting, the following formulas could be used:
    In cell B5 for counting green: =COUNTIFS(C2:Z2,"<>")
    In cell B6 for counting red: =COUNTIFS(C1:Z1,"<"&A2)-C5
    In cell B7 for counting amber: =SUMPRODUCT((C1:Z1<>"")*(C1:Z1-2500<A2))-SUM(C5:C6)
    Note that the formulas may be modified to include as many columns as needed.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  8. #8
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Count coloured cells with conditional formatting

    Quote Originally Posted by kapi98 View Post
    I'm sorry but I'm still confused.
    Could someone clarify?
    He means return the colour produced by the conditional formatting using the DisplayFormat property, like this:
    Please Login or Register  to view this content.
    But you can't use this in a function (you will get a recursive call loop that will error out) so you have to put it in a Sub and call that using a button or worksheet change event.
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Count coloured cells with conditional formatting


    Yes but as I wrote in my previous post, VBA is useless just using formulas like demonstrated within post #7 …

  10. #10
    Registered User
    Join Date
    10-27-2020
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    51

    [SOLVED] Re: Count coloured cells with conditional formatting

    It worked just fine, thanks for your help. Reputation's been added!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA to count coloured cells from Conditional Formatting
    By FraserMc97 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-19-2017, 09:38 AM
  2. How to Setup ranking on coloured cells ( Conditional formatting )
    By fragle2112 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-08-2017, 08:57 AM
  3. [SOLVED] Conditional Formatting Non-Coloured Cells
    By BDBJ1 in forum Excel General
    Replies: 5
    Last Post: 12-16-2015, 01:04 PM
  4. [SOLVED] Counting coloured cells based on conditional formatting
    By Chetansuri in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2014, 08:11 AM
  5. How can I count coloured cells (coloured using Conditional Formatting)
    By franfry in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-15-2013, 02:40 PM
  6. [SOLVED] Adding only cells coloured using conditional formatting
    By FranAgrippina in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 08:49 AM
  7. Count Coloured cells (conditional formatting)
    By MaddieRoberts in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-19-2012, 08:46 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1