+ Reply to Thread
Results 1 to 4 of 4

Count number of coloured cells

  1. #1
    Registered User
    Join Date
    10-15-2018
    Location
    Denmark
    MS-Off Ver
    10
    Posts
    14

    Count number of coloured cells

    Hi all,

    I have attached my workbook.

    I am looking for at solution so count the blue cells per week. See attached image.

    Right now I have used conditional formatting to color the cells, through this formula:

    =AND(M$11>=$J13;M$11<=$K13)

    Then in the green line, where I want to count the amount of colored cells in the week, i have used this code:
    Please Login or Register  to view this content.
    Then added this formula to the cell:
    =GetColorCount(M13:M200;$X$5)

    But due to the cells being colored by conditional formatting this do not work.

    Do you have any suggestions?

    Thanks!2020-02-18_11-40-31.jpg
    Last edited by Pepe Le Mokko; 02-18-2020 at 07:38 AM. Reason: Thread moved to correct sub forum

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Count number of coloured cells

    As the question (and the file) is about UDF, it probably suits better to https://www.excelforum.com/excel-pro...ng-vba-macros/ subforum.

    But anyway:
    Accessing the formatting applied to a cell by conditional formatting is not an easy tesk. so probably it's better to directly count the situations, which are markled by conditional formatting. The simple UDF could be:
    Please Login or Register  to view this content.
    The same could be obtained (and then posting in formulas subforum is just right) with regular formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    (this approach is presented in a copy of original sheet)
    Attached Files Attached Files
    Best Regards,

    Kaper

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Count number of coloured cells

    From XL2010 onwards there's a method called DisplayFormat which is able to count colours from CF.

    Have a look into that.

    Edit: DisplayFormat will only work when called from another sub, not from worksheet. So stick with Kaper's solution.
    Last edited by bakerman2; 02-18-2020 at 08:35 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: Count number of coloured cells

    Attached if interested module using DisplayFormat (as @bakerman2 comments XL2010)
    Button on sheet calls function - conditional format fill colour needs maintaining.
    Downside appears if you use extra conditional formatting (e.g. current week column marker) this confuses the code.

+ 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] HELP! VBA to count number of coloured cells in a column and paste result in seperate tab
    By jordanleewillis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-25-2016, 08:29 AM
  2. 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
  3. macros to count the number of coloured cells?
    By Naja in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2013, 09:44 AM
  4. [SOLVED] Count number of coloured cells
    By nancyching1711 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-26-2012, 01:49 PM
  5. [SOLVED] Count coloured cells
    By ukphoenix in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-29-2012, 11:13 AM
  6. Count coloured cells
    By SoqedHozi in forum Excel General
    Replies: 2
    Last Post: 11-04-2011, 06:49 AM
  7. count coloured cells
    By ile in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-19-2006, 03:40 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