+ Reply to Thread
Results 1 to 14 of 14

Macro that counts cells based on their conditional formatting

  1. #1
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Macro that counts cells based on their conditional formatting

    Howdy!

    I created a function that counts cells based on their background color, but it doesn't work with conditional formatting. I tried using "DisplayFormat" but that gives me an #Value! on the sheet. Does anybody know a workaround? Thanks!

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    07-28-2015
    Location
    Pruszków, Poland
    MS-Off Ver
    365 Business
    Posts
    58

    Re: Macro that counts cells based on their conditional formatting

    Hi, try this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Re: Macro that counts cells based on their conditional formatting

    Still getting #Value! error....

  4. #4
    Registered User
    Join Date
    07-28-2015
    Location
    Pruszków, Poland
    MS-Off Ver
    365 Business
    Posts
    58

    Re: Macro that counts cells based on their conditional formatting

    OK, thats becouse you cannot use this method in worksheet, but in Subs it works fine: https://docs.microsoft.com/en-us/off....displayformat

  5. #5
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Re: Macro that counts cells based on their conditional formatting

    Right I found that too... I'm still looking for a workaround though

  6. #6
    Registered User
    Join Date
    07-28-2015
    Location
    Pruszków, Poland
    MS-Off Ver
    365 Business
    Posts
    58

    Re: Macro that counts cells based on their conditional formatting

    If the purpose is not very wide you can apply the same logic which is in conditional formatting to count trues.

  7. #7
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Re: Macro that counts cells based on their conditional formatting

    That's not really an option, this code is part of a plug-in that I created for my co-workers, and they need to be able to use it everywhere.

  8. #8
    Registered User
    Join Date
    07-28-2015
    Location
    Pruszków, Poland
    MS-Off Ver
    365 Business
    Posts
    58

    Re: Macro that counts cells based on their conditional formatting

    So maybe you can use it in sub-macro and recalculate it on event (for example on any change in worksheet)?

  9. #9
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Re: Macro that counts cells based on their conditional formatting

    I tried that but still gives me #Value! error

  10. #10
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Re: Macro that counts cells based on their conditional formatting

    I even tried this page:
    http://www.cpearson.com/excel/CFColors.htm

    No success....

  11. #11
    Registered User
    Join Date
    07-28-2015
    Location
    Pruszków, Poland
    MS-Off Ver
    365 Business
    Posts
    58

    Re: Macro that counts cells based on their conditional formatting

    Example in the attachment
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Re: Macro that counts cells based on their conditional formatting

    Right, but I need it as a function. What I tried to do was have the function call that sub, but that didn't work

  13. #13
    Registered User
    Join Date
    06-25-2018
    Location
    Madrid, Spain
    MS-Off Ver
    2013
    Posts
    92

    Re: Macro that counts cells based on their conditional formatting

    You gave me an idea though, I decided to go with a button and selectables. Thanks mate!

    Please Login or Register  to view this content.

  14. #14
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Macro that counts cells based on their conditional formatting

    Possibly adapting this (counts all CF cells set to red)...
    Please Login or Register  to view this content.

+ 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] Conditional Formatting based on another cells Conditional Formatting
    By chriskay in forum Excel General
    Replies: 4
    Last Post: 08-22-2019, 05:33 AM
  2. Replies: 1
    Last Post: 10-04-2016, 05:17 AM
  3. Calendar Date Conditional Formatting Counts
    By AlexNorman100 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-22-2016, 09:20 AM
  4. Replies: 1
    Last Post: 08-19-2016, 03:57 PM
  5. Macro to set up conditional message based on results of conditional formatting
    By paysola in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-04-2016, 12:38 AM
  6. Replies: 4
    Last Post: 01-06-2012, 05:07 PM
  7. Conditional Formatting to get top counts in ranges
    By Dynamo418 in forum Excel General
    Replies: 21
    Last Post: 06-30-2010, 04:58 PM

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