+ Reply to Thread
Results 1 to 10 of 10

Counting coloured cells that are conditionally formatted

  1. #1
    Registered User
    Join Date
    09-23-2015
    Location
    Aberdeen, Scotland
    MS-Off Ver
    2010
    Posts
    3

    Counting coloured cells that are conditionally formatted

    I am trying to format a document that counts colours within a row (their colour is determined by conditional formatting) and will turn a cell a certain colour at the end if the number of red cells is above a certain level.

    The issue is the CountCcolour formula doesn't seem to work on coloured cells that are determined by conditional formatting.

    Any help would be much appreciated.

    Thanks

  2. #2
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Counting coloured cells that are conditionally formatted

    Hi vmutch,

    What are the criteria used for the CF to change cells a certain colour? You could probably use that as the criteria to count cells with. If you can post an example, it would help to come up with a solution for you.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Counting coloured cells that are conditionally formatted

    You are right: CF coloured cells cannot be evaluated so you will need to find another solution. Can the result be determined from the data that CF uses?

  4. #4
    Registered User
    Join Date
    09-23-2015
    Location
    Aberdeen, Scotland
    MS-Off Ver
    2010
    Posts
    3

    Re: Counting coloured cells that are conditionally formatted

    Colour counting.JPG

    There are 13 columns which I require the colours to be counted on. Each column has a different formula as to when it turns a certain colour, so I'm presuming it will be quite complicated to do a formula to count each one individually and do the count that way?

    Below is an extract of the cells that require counting, they are simple formulas for the conditional formatting - if greater than 2 for example, but each column has a different cut off.

  5. #5
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Counting coloured cells that are conditionally formatted

    What are the criteria that will turn a cell a certain colour at the end if the number of red cells is above a certain level, e.g. for any one of the 13 cells to turn red does the number entered have to be greater than or equal to a particular value, i.e. zero? If yes, then it should be relatively easy, but if you are able to upload even a cut down version or sample that would make it much easier to provide a working solution.

  6. #6
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Counting coloured cells that are conditionally formatted

    Hi vmutch,

    There appear to be various (complex) VBA solutions to this problem, e.g. this thread http://www.excelfox.com/forum/f22/ge...ng-or-not-338/ amongst others...

    I'm not sure of your exact criteria, but I wondered if this would achieve what you are looking for (see attached). The criteria can be adjusted to suit your needs.

    I've added CF to each column to change the cell colour and to keep it simple assumed that the cell will turn red when the cell value in the first column is greater than 1, in the second column when the cell value is greater than 2, in the third column when the cell value is greater than 3 and so on, but any criteria will work...

    I've then used an array formula to count the number of red cells in the range C7:O7 (on the attached sample) and CF to change the colour of cell Q7 to a specified colour (pink in the sample) when five or more cells in the range C7:O7 turn red. The number of red cells required to turn cell Q7 pink can simply be specified through the CF for cell Q7.

    In Q7 I've added this formula as an array using Control + Shift + Enter.

    Please Login or Register  to view this content.
    Obviously adjust the range to suit. Let me know whether or not this achieves what you want?
    Attached Files Attached Files
    Last edited by HangMan; 09-23-2015 at 07:17 PM.

  7. #7
    Registered User
    Join Date
    09-23-2015
    Location
    Aberdeen, Scotland
    MS-Off Ver
    2010
    Posts
    3

    Re: Counting coloured cells that are conditionally formatted

    Hi, thank you for this. I have applied this to my spreadsheet, but the value in the pink box isn't counting the number or red boxes correctly. I have attached the spreadsheet so you can see what I have done.

    Formula is copies across, but isn't counting the correct amount of red cells.Copy of Conditional Formatting Colour Count - VM.xlsx

  8. #8
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Counting coloured cells that are conditionally formatted

    If the colours are Condtionally Formatted, ie set by a condition then just count the conditions that are true which set the colour in the first place
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Counting coloured cells that are conditionally formatted

    The CFs for the RED (and other colours) vary by COLUMN so counting the conditions means a test for each column.

    C & D <2, E <4 etc

    Confused!!

    If CF rule was >5 is always RED then =COUNTIF(range,">5") would give you the count you require.

  10. #10
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Counting coloured cells that are conditionally formatted

    Hi vmutch,

    My formula in the previous post made the assumption that the cell will turn red when the cell value in the first column is greater than 1, in the second column when the cell value is greater than 2, in the third column when the cell value is greater than 3 and so on because I didn't know the criteria you'd used for your CF, however now that I know that, it makes it easy, you can simply replace the

    Please Login or Register  to view this content.
    with an array that matches your CF criteria to give you

    Please Login or Register  to view this content.
    where {0,1,3,3,3,9,8,0,0,4,0,0,2} matches the CF criteria for columns F:R to turn a cell red for each respective column. I've left column A with the same CF, so that when 5 or more cells turn red, the cell in column A turns 'Red', but just change this to suit your needs. I've also assumed, based on your sample that you are only including columns F:R in your calculation, despite the conditionally formatted cells running from C:R?


    I've noticed that you have some duplication in your CF in some columns which you don't need, so I've removed the following

    Column C - You format cells 'Green' both when > 2 and > 3, I've removed > 3
    Column F - You format cells 'Red' both when > 0 and > 1, I've removed > 1. You also have two instances for formatting cells = '*', you can remove the second instance
    Column G - You format cells 'Red' both when > 1 and > 2, I've removed > 2
    Column J - You are formatting cells 'Light Red Fill with Dark Red Text' for both '*' and when the cell value is between 2 and 3, I've removed the entry for between 2 and 3 as that is covered by Yellow
    Column K - You have three instances where you are formatting cells 'Light Red Fill with Dark Red Text' for '*', I've removed > 9 and the second '*'
    Column K - You also have cells formatted as 'Red' when > 9 and > 10, I've removed > 10
    Column L - You format cells 'Red' both when > 8 and ="8$M$6:$M$18", I've removed ="8$M$6:$M$18"
    Column M - You have two instances where you are formatting '*' as 'Light Red Fill with Dark Red Text', I've removed the second instance
    Column N - You have two instances where you are formatting '*' as 'Light Red Fill with Dark Red Text', I've removed the second instance
    Column O - You have two instances where you are formatting '*' as 'Light Red Fill with Dark Red Text', I've removed the second instance

    Note: on the attached sample, I've removed all the instances of CF for '*' and repalced it with a grey colour for blank cells.


    The 'spanner in the works' is the addition of an '*' that you have included where you have blank cells. This causes an issue which I've not figured out a solution for yet because the '*'s are being counted as if they were numbers and I can't find a way to prevent that, however if the '*'s aren't precious and you would be happy to replace them with say a 'Dark Grey' cell instead (as I've done on the attached file) then that problem goes away and everything should be worknig now hopefully.
    Attached Files Attached Files
    Last edited by HangMan; 09-24-2015 at 02:53 PM.
    Thanks,
    HangMan

    You can say "Thank you!" by clicking Add Reputation below the post.
    Please, mark your thread [SOLVED] if you are happy with the solution.

+ 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] Counting Conditionally Formatted Coloured Cells
    By Tiraenus in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-23-2018, 08:03 PM
  2. counting conditionally formatted columns
    By greengem in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-04-2013, 02:31 AM
  3. counting conditionally formatted cells
    By chop924 in forum Excel General
    Replies: 3
    Last Post: 05-09-2012, 11:44 AM
  4. Counting cells conditionally formatted, by colour
    By edwar368 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2011, 05:30 PM
  5. Sum conditionally formatted cells
    By akabraha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-04-2010, 02:22 PM
  6. Counting by conditionally formatted cells
    By genus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-23-2009, 05:42 AM
  7. Counting conditionally formatted cells
    By Nigel in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-27-2008, 04:00 PM

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