+ Reply to Thread
Results 1 to 21 of 21

Count colours in several set of rows

  1. #1
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10

    Count colours in several set of rows

    Hi good people of Excel land. I'm new here and hope you can help. I've used Excel in a basic form for a while, but am getting to use more and more in depth functions.

    I have 48 rows of data, each row has 3 cells. Each row details information about sensors. I want to count the sensors into three groups: Good, indeterminate and bad.

    I have two reference cells above each column, an upper limit and a lower limit:

    590 170 20
    570 165 18

    xxx yyy zzz
    xxx yyy zzz
    xxx yyy zzz
    xxx yyy zzz
    . . .
    . . .
    . . .

    I use conditional formatting to colour the cells thus:
    cell style GOOD for any cells >= the upper limit.
    cell style NEUTRAL for any cells between the limits.
    cell style BAD for any cells < the lower limit.

    So far so good.

    Now I want three cells set up to count the rows with the following criteria (each row is one sensor):

    Cell #1: ALL cells in a row are GOOD (This sensor is a pass).
    Cell #2: One or more cells in a row are NEUTRAL (Sensor is indeterminate).
    Cell #3: One or more cells in a row are BAD. (No prizes for guessing this one).

    I generate data that has every combination of these. I don't want the same row to be deemed as NEUTRAL and BAD which and give incorrect counts.

    if this needs macros then no problem.

    Any help appreciated.

    Thanks,

    John.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,211

    Re: Count colours in several set of rows

    Welcome to the forum!

    You can't count colours with a formula. You will need to count something else.

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,477

    Re: Count colours in several set of rows

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Quang PT

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Count colours in several set of rows

    As you are using conditional formatting to generate the colours, you can use the same conditions within a COUNTIF function to count how many occur.

    With a sample Excel workbook, it should be easier to set this up for you.

    Pete

  5. #5
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10

    Re: Count colours in several set of rows

    Hi,

    Please find attached an example of the data and colouring.

    I'm aware that counting based on colours is not the way to go and I have tried COUNTIFS to achieve the goal, but it didnta take into account the adjacent call data and either didn't count at all, or couted incorrectly.

    The actual counts in the example are manual.

    John.
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,211

    Re: Count colours in several set of rows

    Cell #2: One or more cells in a row are NEUTRAL (Sensor is indeterminate).
    Cell #3: One or more cells in a row are BAD. (No prizes for guessing this one).
    How will you break a tie? What if there is one of each in the row, along with a green - what should the outcome be?

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Count colours in several set of rows

    It might be easier to use column F as a helper to check each sensor - put this formula in F7:

    =IF(AND(C7>=C$2,D7>=D$2,E7>=E$2),"Good",IF(OR(C7<=C$4,D7<=D$4,E7<=E$4),"Fail","?"))

    then copy down. Then it would be quite easy to generate your summary table using COUNTIF.

    Hope this helps.

    Pete

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Count colours in several set of rows

    @Ali,

    As I understand it, only if ALL 3 are green does it pass, and if any single one is red then it fails.

    Hope this helps.

    Pete

  9. #9
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10

    Re: Count colours in several set of rows

    Hi,

    If there is at least one NETURAL in a row (the rest GOOD), then the sensor is indeterminate, so the indeterminate count increments by 1.
    If there is at least one BAD (The others can be GOOD or NEUTRAL) the sensor is bad, so the bad count increments by 1.

    John.

  10. #10
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10

    Re: Count colours in several set of rows

    ....and yes, if all cells in a row are GOOD, the good count increments by 1.

    John

  11. #11
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10

    Re: Count colours in several set of rows

    Hi Pete,

    Extreme thanks for coming up with this! I'll hide the column and as you said, do a count from this.

    Perfect.

    John.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,211

    Re: Count colours in several set of rows

    I don't think you need a helper column - I have almost worked out a solution. Please hold fire!

  13. #13
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10

    Re: Count colours in several set of rows

    I is holdin'.....

    The helper column works but I'm open to all help!

    john.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,211

    Re: Count colours in several set of rows

    I've hit a roadblock. This works for good:

    =COUNTIFS($C$7:$C$54,">="&C2,$D$7:$D$54,">="&D2,$E$7:$E$54,">="&E2)

    I am just working out the other two.

  15. #15
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10

    Re: Count colours in several set of rows

    Many thanks for all help so far!

    I need to account for blank cells and not include them in the counts.

    The results are copy & pasted from the tester software, so all three cells are populated one row at a time.

    Just to make your job more interesting.

    John.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,211

    Re: Count colours in several set of rows

    ... and on that bombshell ...

    The garden is calling me. Feel free to mark this as solved!

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,211

    Re: Count colours in several set of rows

    Just out of curiosity, you said this:

    I need to account for blank cells and not include them in the counts.
    If one or more of the three in a row are blank, what should happen?

    1. The row is entirely disregarded?

    2. 2 green and a blank returns the same as 3 green?

    3. Something else?

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,211

    Re: Count colours in several set of rows

    Anyway, it can be done without a helper column as it stands.

    In H2: =COUNTIFS($C$7:$C$54,">="&C2,$D$7:$D54,">="&D2,$E$7:$E$54,">="&E2)

    In H3: =ROWS($C$7:$E$54)-H2-H4

    In H4: =SUM(--(MMULT(--($C$7:$E$54<$C$4:$E$4),TRANSPOSE(COLUMN($C$7:$E$54)))>0))

    H4 needs to be confiurmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Excel 2016 (Windows) 32 bit

    G
    H
    2
    Good:
    13
    3
    ?:
    3
    4
    Bad:
    32
    Sheet: Sheet1
    Last edited by AliGW; 04-19-2019 at 04:36 AM.

  19. #19
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10
    Hi and thanks for the help. It will be Tuesday before I can try it do will be back to let you know how it went.

    John.
    Last edited by AliGW; 04-20-2019 at 02:18 AM.

  20. #20
    Registered User
    Join Date
    04-18-2019
    Location
    Poulton-le-Fylde
    MS-Off Ver
    365 Business
    Posts
    10

    Re: Count colours in several set of rows

    Hi AliGW,

    This works a treat so will implement it forth, fifth & sixth with.

    John.

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,211

    Re: Count colours in several set of rows

    Glad to have helped and thanks for letting me know.

+ 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] Count four colours
    By I need excel help in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-08-2018, 01:06 PM
  2. How do I count how many times two colours appear together?
    By mthomas66 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2014, 05:34 PM
  3. Replies: 1
    Last Post: 05-08-2013, 08:49 AM
  4. Is there a formular in Excel that can count the colours of a cell?
    By petedacreep in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-06-2012, 05:46 AM
  5. Replies: 25
    Last Post: 03-29-2010, 03:23 PM
  6. Count Cell Colours
    By Stevesmith in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-27-2007, 08:46 AM
  7. Count If on colours in a cell?
    By Jelinek in forum Excel General
    Replies: 2
    Last Post: 05-11-2006, 06:40 AM

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