+ Reply to Thread
Results 1 to 11 of 11

conditional formatting for multiple columns and count cells based on colors

  1. #1
    Registered User
    Join Date
    03-04-2017
    Location
    NJ
    MS-Off Ver
    Excel for Mac Version 15.31
    Posts
    75

    conditional formatting for multiple columns and count cells based on colors

    Dear Excel Community,

    I have a two-part problem that I need help with. If you can help with either part, that would be so great.

    Attached is a workbook with two sheets. The second sheet, "fall test results", is where data on the first sheet populate and it's the second sheet that I need help with. Currently, I have 3 columns "quiz 1, quiz 2 and quiz 3" that need to have conditional formatting and each column has its own values and cutoffs. So for example, for quiz 1, there needs to be 3 colors based on the following values: if between 0 and 24, then pink, if between 25 and 39, then yellow, if greater than 40, then green. Quiz two has the same 3 colors but with different cutoff values, etc. I currently have to go into each column, specify the conditional formatting and it becomes unwieldy when the actual sheet has 10-15 columns like these.

    Request #1: I wonder if there's a vba that allows me to specify the cutoff values for each column in one go? I believe that doing so would be quicker, and by putting all the cutoffs in one place, it's easier for me to eyeball and double check my cutoffs so that I don't accidentally input the wrong cutoff values for the conditional formatting.

    After I'm done with the conditional formatting starting from row 10 all the way down to row 1007, I need to go the boxes at the very top of the page (row 2 through row 6) and do a count based on the values from row 10-1007. Right now, what I do is input 3 formulas with the cutoffs once again for each quiz so that it can count for me. But this is very error prone--with so many cutoff values for different quizzes and having to put the same formulas twice, I've made mistakes in the past. So...

    Request #2: is there a way for me to do a count based on the colors that poplate from row 10 in column C, D, and E?

    I've attached my workbook for your review.

    I realize that this is a large request, so any general or specific advice to streamline this process (VBA or not) would be greatly appreciated. Thank you so much and have a wonderful day!

    Anita
    Last edited by anita2017; 08-16-2020 at 10:12 AM.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: conditional formatting for multiple columns and count cells based on colors

    hi Anita,

    I remember you from last time.

    you said: Currently, I have 3 columns "quiz 1, quiz 2 and quiz 3" that need to have conditional formatting and each column has its own values and cutoffs. ......

    I currently have to go into each column, specify the conditional formatting and it becomes unwieldy when the actual sheet has 10-15 columns like these.


    yeah, but that's the easiest way to do it. what's wrong with it doing it manually one time only?

    regarding your 1st request: I wonder if there's a vba that allows me to specify the cutoff values for each column in one go? I believe that doing so would be quicker, and by putting all the cutoffs in one place, it's easier for me to eyeball and double check my cutoffs so that I don't accidentally input the wrong cutoff values for the conditional formatting.

    if the cutoff values never change, code isn't going to do anything for you. now, if values were constantly changing, obviously code would help. push a button, read the bound limits from the book somewhere and update.

    #2: Request #2: is there a way for me to do a count based on the colors that poplate from row 10 in column C, D, and E?

    actually I don't think so. there is a function called COUNTIF(), but the arguments don't allow colors to be specified I don't think. because that would be a method inside of a function. but you can do this with code.

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,624

    Re: conditional formatting for multiple columns and count cells based on colors

    on results sheet, insert a column for the cutoff ranges for each quiz.
    For conditional formatting row 10 and below,
    upper cutoff (green):
    Please Login or Register  to view this content.
    yellow:
    Please Login or Register  to view this content.
    red:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    03-04-2017
    Location
    NJ
    MS-Off Ver
    Excel for Mac Version 15.31
    Posts
    75

    Re: conditional formatting for multiple columns and count cells based on colors

    Hi Adam,

    Thanks for your input. Your points are well-taken and thank you for pointing out that I can't do the request #2 using VBA.

    Anita

  5. #5
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: conditional formatting for multiple columns and count cells based on colors

    Quote Originally Posted by anita2017 View Post
    Hi Adam,

    Thanks for your input. Your points are well-taken and thank you for pointing out that I can't do the request #2 using VBA.

    Anita
    please look at the other response from Ben Van Johnson. he knows more than me about what will work and what doesn't. please post here when you find a solution

  6. #6
    Registered User
    Join Date
    03-04-2017
    Location
    NJ
    MS-Off Ver
    Excel for Mac Version 15.31
    Posts
    75

    Re: conditional formatting for multiple columns and count cells based on colors

    Hi protonLeah,

    Your solutions are really clever! I think it's such a great idea to insert a column to the boxes at the top specifying the cutoff values and build the formulas from there. The displayed cutoffs make it easy for teachers to see as they currently have to click on each cell to reveal those values and the huge plus is I only have to specify these values once, which gets cumbersome and error prone when I have so many columns to deal with at once.

    Now, going to the conditional formatting piece, I have a general understanding of what you're doing and it looks like it will save me tons of hours because I get to apply conditional formatting rules to all columns, rather than doing it one column at a time. If it's not too much trouble, would you explain in plain English what these formulas are saying for each color, or just for yellow?

    Thank you again so much for your solutions!

    Anita

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,624

    Re: conditional formatting for multiple columns and count cells based on colors

    The conditional formatting formulas are using OFFSET($A$1,3,MATCH(C$9,$1:$1,0),3,1) to find the appropriate cutoff range based on the column headers starting in C9.
    For instance, for cell D10, the MATCH fn looks up "quiz 2" in row 1 and returns 6 to the OFFSET fn as column offset from A1. Since the row offset is hard coded as 3, cell G4 is the top cell of a three cell high range (90,74,55). That range returned to the MAX/MIN fns for the comparison calculations.

  8. #8
    Registered User
    Join Date
    03-04-2017
    Location
    NJ
    MS-Off Ver
    Excel for Mac Version 15.31
    Posts
    75

    Re: conditional formatting for multiple columns and count cells based on colors

    Hi Ben,

    Many thanks for your explanation. I'm learning a lot from your excel formulas and solutions!

    Have a wonderful day!
    Anita

  9. #9
    Registered User
    Join Date
    03-04-2017
    Location
    NJ
    MS-Off Ver
    Excel for Mac Version 15.31
    Posts
    75

    Re: conditional formatting for multiple columns and count cells based on colors

    Hi Ben,

    I hope it's okay to ask a follow up question on a solved thread. I'm now testing each part of your conditional formula one step at a time to understand. Broadly speaking, I understand what you did based on your explanation above. However, regarding the match function and its arguments, I see that the reference column and row you entered is C$9. Which part of your entire formula tells excel to look up the value in C$9 and then D$9 and then E$9 in order to return appropriate ranges of scores? I could get excel to return a value of 6 only if I use match(D$9, $1:$1,0) but this is clearly not what you did as all of your formulas in the conditional formatting section only referenced C$9.

    Thanks for your guidance!

    Anita

  10. #10
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,624

    Re: conditional formatting for multiple columns and count cells based on colors

    Because the conditional format formula is applied over a specific range,
    =$C$10:$E$1007
    you can think of the formula as written in each cell, with Excel automatically adjusting the cell addresses to reference that particular cell. For instance the formula:

    =AND(C10<>"",C10<=MIN(OFFSET($A$1,3,MATCH(C$9,$1:$1,0),3,1)))

    when applied to, say, D13 will be evaluated as:

    =AND(D13<>"",D13<=MIN(OFFSET($A$1,3,MATCH(D$9,$1:$1,0),3,1)))
    Last edited by protonLeah; 08-19-2020 at 03:37 PM.

  11. #11
    Registered User
    Join Date
    03-04-2017
    Location
    NJ
    MS-Off Ver
    Excel for Mac Version 15.31
    Posts
    75

    Re: conditional formatting for multiple columns and count cells based on colors

    Oh I see. Thanks so very much for your expertise!

    Anita

+ 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. Replies: 0
    Last Post: 06-15-2017, 06:28 PM
  2. Replies: 2
    Last Post: 12-05-2016, 10:59 AM
  3. [SOLVED] Conditional formatting to change colors of Columns based on data entered in Column E
    By JJFletcher in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-13-2016, 01:27 PM
  4. [SOLVED] Fill colors of cells using Conditional formatting based on 3 criteria
    By Sai Prashanth in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-22-2014, 12:39 PM
  5. [SOLVED] Count cells based on Conditional formatting
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2014, 03:41 PM
  6. Replies: 1
    Last Post: 08-20-2012, 10:36 PM
  7. Count colors with conditional formatting
    By vinaysalian17 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2007, 02:50 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