+ Reply to Thread
Results 1 to 11 of 11

Count cells in a row that are "color" conditionally formatted by column

  1. #1
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Count cells in a row that are "color" conditionally formatted by column

    Count cells in a row that are "color" conditionally formatted by column.


    I need to count all the cells in a row that are automatically highlighted by conditional formatting (which is done by column).

    In the attached file, in cell Q3, it should say 2 (since there are only two conditionally formatted cells for Group 1). In cell T3, it should show 2 also since only two cells have been conditionally highlighted for that group 2. In the next row 4, group one should show 2 and group two should show zero. In row 5, "Group 1" should show 3 and "Group 2" should show 2. Etc. etc.

    This repeats per row.

    I have tried with the obvious VBA but I can't make it work. All I get is #VALUE!

    Thanks so much in advance.

    Ps. I searched through the forum, here and elsewhere, but I was not able to find a working solution for this particular scenario. I found some similar, but not quite the same and I couldn't adapt their solutions.
    Attached Files Attached Files

  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
    80,779

    Re: Count cells in a row that are "color" conditionally formatted by column

    Is this a VBA question or a formula one?

    If the latter, you can use the CF rule in a COUNTIFS formula.
    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 Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Count cells in a row that are "color" conditionally formatted by column

    Can you please show me how? That's why I'm here, because I don't know how to do so. Can you do it with the attached file so I can see a working solution?

    Thanks.

  4. #4
    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
    80,779

    Re: Count cells in a row that are "color" conditionally formatted by column

    You haven't answered the question - are you looking for a VBA or a formula solution? You mention VBA, and there's no point in my showing you a formula solution if it's not what you want. Please clarify.

  5. #5
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Count cells in a row that are "color" conditionally formatted by column

    Thanks for replying.

    I would prefer a formula. However, if you can also teach me how to do it with VBA? I already tried with VBA to no avail. That's what the attached file has. Again, I think a formula is the easiest way to manipulate it later on.

    Thanks again.

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

    Re: Count cells in a row that are "color" conditionally formatted by column

    Not eloquent, however it yields the expected results.
    Paste the following into cell Q3 and drag the fill handle down to cell Q12:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    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.

  7. #7
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Count cells in a row that are "color" conditionally formatted by column

    Thank you JeteMc.

    It worked exactly as needed.

    I do have some questions.

    One: I tried to use the same formula (using it in cell U3) for "Group 2" which goes from column I through L but it only works if I add a -1 at the end of the formula.

    In other words, THIS WORKS:
    =SUM(SUMPRODUCT(--(MAX(I$3:I$12)=I3)),SUMPRODUCT(--(MAX(J$3:J$12)=J3)),SUMPRODUCT(--(MAX(K$3:K$12)=K3)),SUMPRODUCT(--(MAX(L$3:L$12)=L3))-1)

    But this does not (and this is based on the original formula you gave me), so the question is why not? - I simply want to understand why not since it's the same logic/procedure as the first group.
    =SUM(SUMPRODUCT(--(MAX(I$3:I$12)=I3)),SUMPRODUCT(--(MAX(J$3:J$12)=J3)),SUMPRODUCT(--(MAX(K$3:K$12)=K3)),SUMPRODUCT(--(MAX(L$3:L$12)=L3)))


    Second: How do I go about "adding" the values of those highlighted cells independently of the first formula which counts them? Since the formula to count them is using "Sum" I got stopped on my tracks when thinking how to adapt your formula to add. I need this "adding" to start in cells R3 (and below) and V3 (and below).

    Please see attached file. Note: the "Count" formulas are working. I only provide this attachment to illustrate the "adding" values needed in columns R and V.

    Thank you so much.
    Attached Files Attached Files

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

    Re: Count cells in a row that are "color" conditionally formatted by column

    The formula is calculating all the blank cells in column L as zeros, as illustrated when using the Evaluate Formula feature, so they are all the MAX value in that column and therefore all counted. Your "-1" formula will work as will the following:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    As for the Sum based on the top/MAX values from each column try pasting the following into cell R3 and copying down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  9. #9
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Count cells in a row that are "color" conditionally formatted by column

    Thank you so much.

    I understand now.

    The second formula worked as needed too.

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

    Re: Count cells in a row that are "color" conditionally formatted by column

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

  11. #11
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Count cells in a row that are "color" conditionally formatted by column

    Mark solved: Done.

    You too have a blessed day and be safe.

+ 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. How to prevent conditionally formatted cell from "moving"?
    By KaleNovice in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-26-2019, 01:01 AM
  2. [SOLVED] How to extract conditionally-formatted "highlighted" cell data
    By dvess11 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-14-2018, 10:22 AM
  3. How to count and sum "Condtional formatting" cells by color ?
    By coniconi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-13-2017, 08:28 AM
  4. Replies: 1
    Last Post: 03-27-2014, 08:57 PM
  5. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  6. Replies: 1
    Last Post: 07-16-2010, 02:44 AM
  7. [SOLVED] cells formatted to tick when text value "Y" if or null if "N"
    By Jay in forum Excel General
    Replies: 7
    Last Post: 01-13-2006, 05:20 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