+ Reply to Thread
Results 1 to 14 of 14

Conditional formatting to highlight multiple values with single rule?

Hybrid View

  1. #1
    Registered User
    Join Date
    05-25-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    4

    Question Conditional formatting to highlight multiple values with single rule?

    I have a large spreadsheet and use conditional formatting to highlight the cell background of particular values (which are numbers). I have approximately 20 values that I need highlighted.

    At the moment, I have a separate conditional formatting rule set up for each value I am interested in. However, it would be preferable if I could have a single conditional formatting rule/formula to do this, as the values I am interested in change from time to time and it would be faster to update a single formula.

    Is it possible to do this?

    For example, in my spreadsheet, I want to highlight any cell that has values 3, 42, 65, 87 etc.

    Thanks in advance!
    Last edited by chapzboy; 05-27-2015 at 11:00 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,317

    Re: Conditional formatting to highlight multiple values with single rule?

    If you list the values in a range somewhere, you could name that range and then use a COUNTIF function to check if the value is present.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    07-25-2012
    Location
    Winterville, NC
    MS-Off Ver
    Excel 2013
    Posts
    141

    Re: Conditional formatting to highlight multiple values with single rule?

    You could use conditional formatting based on a formula and use an OR formula. Then you'd just update the "applies to" box to include the entire range to apply the conditional formatting.

  4. #4
    Registered User
    Join Date
    05-25-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Conditional formatting to highlight multiple values with single rule?

    Thanks for the replies. How would I structure the OR formula?

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,317

    Re: Conditional formatting to highlight multiple values with single rule?

    Suggest you post a sample workbook so we have something to play with.

    Regards, TMS

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Conditional formatting to highlight multiple values with single rule?

    You could have a list of numbers to be triggers for formatting then select the range that you want to have the Conditional Formatting applied to and use this formula.

    Formula: copy to clipboard
    =COUNTIFS($I$1:$I$10,A1)>0


    This example uses values entered in column A being formatted if the value is in column I. If the value in column A is a value in column I then it will be formatted according to the format that you choose
    Attached Files Attached Files
    Last edited by newdoverman; 05-25-2015 at 03:44 PM.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,317

    Re: Conditional formatting to highlight multiple values with single rule?

    Dynamic Named Range: nrHL:
    Formula: copy to clipboard
    =Criteria!$A$2:INDEX(Criteria!$A:$A,COUNTA(Criteria!$A:$A))


    Conditional Formatting Formula:
    Formula: copy to clipboard
    =COUNTIF(nrHL,$A2)


    Applied to cells:
    Formula: copy to clipboard
    =$A$2:$C$23


    Built on the Sample Workbook provided by newdoverman

    Please see the updated example,


    Regards, TMS
    Attached Files Attached Files

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Conditional formatting to highlight multiple values with single rule?

    This is the same logic just as TMS done with a different formula for the Named Range. This just shows a second way to create the dynamic criteria range. I'm not saying better, just different.


    Named Range: CFList......
    Formula: copy to clipboard
    =OFFSET(Sheet2!$A$1,0,0,COUNTA(Sheet2!A:A))


    Conditional Format formula:

    Formula: copy to clipboard
    =COUNTIF(CFList,A2)

    This is the same as TMS just to show that the named range, CFList on Sheet2 works.

    The use of a dynamic list for the criteria allows you to add or subtract from the criteria listing as required. There are a lot of applications for dynamic ranges so it is worth while checking out how they work.
    Attached Files Attached Files

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,317

    Re: Conditional formatting to highlight multiple values with single rule?

    @newdoverman: thanks for the feedback and rep

    I'm not saying better, just different.
    I would hazard different, not better OFFSET is volatile, INDEX isn't, hence my preference for INDEX in creating Dynamic Named Range(s).

    The DNR I set up referred to a second sheet, Criteria


    Regards, TMS

  10. #10
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Conditional formatting to highlight multiple values with single rule?

    You're welcome. I think that the additions you made were important.

    I think that the addition of the second worksheet was also a good idea as there could be various lists needed for the workbook that would not be ideally suited to being on the main worksheet. This should be better being on another worksheet.

  11. #11
    Registered User
    Join Date
    05-25-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Conditional formatting to highlight multiple values with single rule?

    Thanks everyone for the replies. I managed to have got it working as I need using the named range on a separate worksheet solution. One further question: in the conditional formatting formula =COUNTIF(CFList,A2) (for example), what is A2 referring to? I had to change this to A1 to get the correct cells (as defined in my named range) to be conditionally formatted.

    Thanks again - there is no way I would have been able to work out how to do this without your advice!

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,317

    Re: Conditional formatting to highlight multiple values with single rule?

    Usually, row 1 would be a header row and your data would start in row 2. So, typically, you would select row 2 down and your CF Formula MUST refer to the first row of the selection.


    Regards, TMS



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  13. #13
    Registered User
    Join Date
    05-25-2015
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: Conditional formatting to highlight multiple values with single rule?

    Ok, just to be clear, you are saying that because row 1 in sheet 1 of the Conditional Formatting - ndm(2) spreadsheet is a blank (header) row, the conditional formatting rule refers to A2, whereas if there is no header row, the formula would need to refer to A1?

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,317

    Re: Conditional formatting to highlight multiple values with single rule?

    I'm saying that, if, say, you select cells A2:A200 before applying the CF Rules, your formula must refer to cell A2. If you select cells A3:A200 before applying the CF Rules, your formula must refer to cell A3. Select cells A4:A200 before applying the CF Rules, your formula must refer to cell A4.

+ 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: 4
    Last Post: 07-25-2014, 05:17 AM
  2. [SOLVED] A conditional formatting rule that will highlight a cell based on certain criteria/date
    By FEL2014 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-24-2014, 03:51 PM
  3. Replies: 5
    Last Post: 07-03-2013, 12:51 AM
  4. [SOLVED] Fx to highlight multiple values from a list using conditional Formatting
    By HooligaD in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-08-2013, 03:03 PM
  5. Conditional Formatting of Multiple Values in a Single Cell
    By mliang87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-19-2013, 06:44 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