+ Reply to Thread
Results 1 to 15 of 15

Conditional formatting - coloring cells across array if value exists in a list

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Conditional formatting - coloring cells across array if value exists in a list

    I haven't been able to find an answer yet to this issue, maybe someone can help:

    I have an array of cells, let's call it A1:D5 for simplification. In each of these cells are various different 4-digit numbers (codes). I also have a short list of codes in a column F1:F5 that fit into a certain category that I'm looking into. My question is this:

    How do I write a formula in conditional formatting that I can apply to the entire array A1:D5 that checks if the value of EACH INDIVIDUAL CELL in that array (A1:D5) contains a value that exists in F1:F5 and turns those cells blue if that condition is satisfied?

    I can format each cell by itself using =Countif(F1:F5,A1)>0 for A1, but I want to apply this over the whole array A1:D5 all at once and have the condition apply to each cell by itself but not the whole array.

    Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Conditional formatting - coloring cells across array if value exists in a list

    Use MATCH.

    Select A1:D5, goto conditional formatting and enter this formula,
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and format as required.
    If posting code please use code tags, see here.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Conditional formatting - coloring cells across array if value exists in a list

    Could be tricky as Conditional formatting doesn't accept array formulas. So do each of these cells only contain 1 code or are we looking for a sub division of the cell to match what's in F1:F5?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Conditional formatting - coloring cells across array if value exists in a list

    ChemistB

    Never thought that there could be more than one value in the cells.

  5. #5
    Registered User
    Join Date
    12-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Conditional formatting - coloring cells across array if value exists in a list

    The cells only contain one value each, but this formula you provided doesn't work.

    Quote Originally Posted by Norie View Post
    Use MATCH.

    Select A1:D5, goto conditional formatting and enter this formula,
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and format as required.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Conditional formatting - coloring cells across array if value exists in a list

    I dont't know if it makes a difference but there is a typo int he formula.

    It should be this.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    That formula and the original worked for me, how are you applying the conditional formatting?
    Last edited by Norie; 12-05-2012 at 12:22 PM.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Conditional formatting - coloring cells across array if value exists in a list

    I would use a dummy column which you can hide
    In H1 dragged down, for example
    =SUM(IF(ISNUMBER(MATCH($A1:$D1,$F$1:$F$5,0)),1,0)) entered as an array (use CONTRL SHFT ENTER instead of ENTER. You'll see {} around your formula)
    Then for the conditional formatting
    Select A1:D5> use formula
    =$H1=4 Format as desired
    Would that work for you?
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Conditional formatting - coloring cells across array if value exists in a list

    Norie,
    I think mudder wants the row highlighted if only if all values in the row are in F1:F5. I believe your formula highlights individual cells if they are in F1:F5. It would make it fairly easy to tell at a glance that all cells in a row are highlighted and thus in the list so might be good enough if mudder doesn't want to go with the dummy column.

  9. #9
    Registered User
    Join Date
    12-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Conditional formatting - coloring cells across array if value exists in a list

    No you've misunderstood, I want each individual cell to be highlighted. Using the sample book you selected, I'd want every cell in A1:D5 that contains either a 2, 3, 5, 7, or 8 to be highlighted, nothing about any particular row.

    Quote Originally Posted by ChemistB View Post
    Norie,
    I think mudder wants the row highlighted if only if all values in the row are in F1:F5. I believe your formula highlights individual cells if they are in F1:F5. It would make it fairly easy to tell at a glance that all cells in a row are highlighted and thus in the list so might be good enough if mudder doesn't want to go with the dummy column.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Conditional formatting - coloring cells across array if value exists in a list

    I didn't notice anything about rows.

  11. #11
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Conditional formatting - coloring cells across array if value exists in a list

    Just tried Norie's corrected CF formula.

    =MATCH(A1,$F$1:$F$5,0)

    It works perfectly.

    - Moo

  12. #12
    Registered User
    Join Date
    12-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Conditional formatting - coloring cells across array if value exists in a list

    Yes I'm not saying that this formula doesn't work, but it doesn't do what I'm looking for. I can conditionally format A1 alone easily in several different ways -- I want to format EVERY CELL in A1:D5 using this same condition all at once.


    Quote Originally Posted by Moo the Dog View Post
    Just tried Norie's corrected CF formula.

    =MATCH(A1,$F$1:$F$5,0)

    It works perfectly.

    - Moo

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Conditional formatting - coloring cells across array if value exists in a list

    Did you select A1:D5 and use the formula I suggested?

  14. #14
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Conditional formatting - coloring cells across array if value exists in a list

    Yes, do what Norie said, select from A1:D5, THEN apply the CF so it applies to all cells in that range. Assumed you were doing that before.

    - Moo

  15. #15
    Registered User
    Join Date
    12-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Conditional formatting - coloring cells across array if value exists in a list

    My bad! It works, thank you!

    Quote Originally Posted by Norie View Post
    Did you select A1:D5 and use the formula I suggested?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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