+ Reply to Thread
Results 1 to 7 of 7

Not getting the expected results from conditional formatting

  1. #1
    Registered User
    Join Date
    01-06-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    2

    Not getting the expected results from conditional formatting

    I've been working on this for the last hour and can't figure out why it's not working. I'm using Excel 2010 and I've attached the spreadsheet for reference. For the Questions table, I'm trying to apply a conditional formatting rule to that table. I'm using this formula: =$J7 > (COUNTA(B7:B41)*0.5). Essentially, if >50% of the students miss this question, then apply the formatting rule (so I think). If the value in J is greater than 8, then the entire row should be formatted, right? In my spreadsheet, I have 16 students, so half would be 8. As you you can see from the attached spreadsheet, in column J I have a varying range of values. The formatting is really, really weird. For some values, the entire row is filled in; for others, only two of the cells are filled in. But, if the value in J is > 8, then the entire row should be filled in, but it's not for a number of rows. Why is this happening? Thanks in advance!
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Not getting the expected results from conditional formatting

    In your uploaded file the format is working but probably in not the way you intend.

    In the relative / absolute addressing in your formula =$J7 > (COUNTA(B7:B41)*0.5 I'm not

    exactly certain how Excel is interpreting the relative cell addressing in the

    COUNTA(B7:B41) part. I tried applying absolute addressing to COUNTA.......$B$7:$B$41 and

    the results highlighted H7:J10 as well as H20:J21 which is what I suspect you want to happen

    and is consistent with values greater than half the student count (8).

    Try changing COUNTA(B7:B41) to COUNTA($B$7:$B$41) to see.
    Last edited by FlameRetired; 01-07-2015 at 12:51 AM.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Not getting the expected results from conditional formatting

    If you use a formula like COUNTA(B7:B41) in CF (actually at any time) without "fixing" or absoluting the range, and you copy that CF rule down, the cell refs inside the function change accordingly...
    H7=COUNTA(B7:B41)
    H8=COUNTA(B8:B42)
    H9=COUNTA(B9:B43)

    I7=COUNTA(C7:C41)
    I8=COUNTA(C8:C42)
    I9=COUNTA(C9:C43)
    etc

    To overcome this, you need to change that to...
    =COUNTA($B$7:$B$41) with the rest of your formula, of course.

    As a tip, sometimes, when CF is not behaving as you expect, put that same formula from CF into the worksheet itself, and copy down - then you can look at how the references are behaving, and adjust as needed
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Not getting the expected results from conditional formatting

    Thanks for that explanation, Ford. I could not understand just how CF was interpreting that part of the formula. This explains a lot.

  5. #5
    Registered User
    Join Date
    01-06-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    2

    Re: Not getting the expected results from conditional formatting

    @FlameRetired--thank you! That fixed it. I didn't even think about the absolute relative addressing in the formula--I just assumed it wouldn't change. I even told myself to fix the range, but figured that probably wasn't the cause. Thank you again!
    Last edited by thoughtreactor; 01-07-2015 at 10:44 AM. Reason: typo

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Not getting the expected results from conditional formatting

    Im happy that explained it for you, thanks for the feedback

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Not getting the expected results from conditional formatting

    Quote Originally Posted by thoughtreactor View Post
    @FlameRetired--thank you! That fixed it. I didn't even think about the absolute relative addressing in the formula--I just assumed it wouldn't change. I even told myself to fix the range, but figured that probably wasn't the cause. Thank you again!
    You're welcome and thanks for the rep!

+ 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 not working as expected
    By SEMMatt in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-25-2014, 09:53 PM
  2. [SOLVED] Multiple results for Conditional Formatting
    By jimbokeep in forum Excel General
    Replies: 4
    Last Post: 07-04-2013, 06:06 AM
  3. Conditional Formatting - No Results
    By toclare84 in forum Excel General
    Replies: 2
    Last Post: 02-08-2012, 10:59 AM
  4. saving a xls as a csv - not getting expected results
    By Caconz in forum Excel General
    Replies: 4
    Last Post: 08-23-2010, 06:40 PM
  5. Filtering by Results of Conditional Formatting
    By excelCPA in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-25-2006, 04:23 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