+ Reply to Thread
Results 1 to 9 of 9

Simplifying conditional formatting based on multiple possible text entries.

  1. #1
    Registered User
    Join Date
    05-19-2010
    Location
    New York
    MS-Off Ver
    MS365 Version 2306
    Posts
    35

    Simplifying conditional formatting based on multiple possible text entries.

    This is a follow up question on a solution I obtained here many years ago (One of many, thank you)

    I have a very long conditional formatting equation for a group of cells that format a cell with a text entry based on the text entry of the cell to its left. The text are simple letters.
    For example if the cell in question is D and the cell to the left is any of the letters A, T, P, U, H, E, or N the cell with D in it will format to Yellow. The problem is that I have 6 different letters that can be in place of D and still need to highlight yellow so I have an OR(AND statement in the formula bar.
    A section of it would look like this

    =OR(AND(C5="D",B5="A"),AND(C5="Z",B5="A"),AND(C5="F",B5="A"),AND(C5="Q",B5="A"),AND(C5="B",B5="A"),AND(C5="G",B5="A"),AND(C5="D",B5="T"),AND(C5="Z",B5="T"),AND(C5="F",B5="T"),AND(C5="Q",B5="T"),AND(C5="B",B5="T"),AND(C5="G",B5="T"))

    I am using a statement for every possibility

    Is there a proper way of simplifying the formula. I want to be able to say if C5 is "Z", or "D" or " F" etc and B5 is "A", or " T", or "U" etc to format C5 to yellow.

    Thank you,
    Stuart

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Simplifying conditional formatting based on multiple possible text entries.

    You did not give a complete list of the valid letters (you can't write a formula with "etc") so I can't give you a complete answer but here is the idea.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-19-2010
    Location
    New York
    MS-Off Ver
    MS365 Version 2306
    Posts
    35

    Re: Simplifying conditional formatting based on multiple possible text entries.

    Appreciate the quick reply and I think that is close (and much shorter than what I had.)
    This is what I entered as a formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Many of the cells are empty on my sheet and many of those are being highlighted yellow as well as a few cells with letters entered with no entry to the left.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Simplifying conditional formatting based on multiple possible text entries.

    Sorry, if C5 is blank then it will return a 1. Try this:

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

  5. #5
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,909

    Re: Simplifying conditional formatting based on multiple possible text entries.

    Or try:

    =(LEN(B5)=1)*(LEN(C5)=1)*FIND(B5,"ATPUHEN")*FIND(C5,"ZDF")

  6. #6
    Registered User
    Join Date
    05-19-2010
    Location
    New York
    MS-Off Ver
    MS365 Version 2306
    Posts
    35

    Re: Simplifying conditional formatting based on multiple possible text entries.

    Quote Originally Posted by 6StringJazzer View Post
    Sorry, if C5 is blank then it will return a 1. Try this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This worked better most of the blank cells that were formatting were fine but any blank cell before a D, Z, F, B, G or Q would format yellow.

    The formula from Phuocam did work though so all is good. I really appreciate the help.

  7. #7
    Registered User
    Join Date
    05-19-2010
    Location
    New York
    MS-Off Ver
    MS365 Version 2306
    Posts
    35

    Re: Simplifying conditional formatting based on multiple possible text entries.

    Quote Originally Posted by Phuocam View Post
    Or try:

    =(LEN(B5)=1)*(LEN(C5)=1)*FIND(B5,"ATPUHEN")*FIND(C5,"ZDF")
    This worked
    If I am reading what you did correctly all 4 criteria have to be fulfilled (1) to format. The LEN function makes sure something is entered in both cells and the find looks for any of my letters. Any one not present gives 0 and no format.

    Very elegant. Thank you

  8. #8
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,909

    Re: Simplifying conditional formatting based on multiple possible text entries.

    You're welcome!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  9. #9
    Registered User
    Join Date
    05-19-2010
    Location
    New York
    MS-Off Ver
    MS365 Version 2306
    Posts
    35

    Re: Simplifying conditional formatting based on multiple possible text entries.

    I had a couple of hiccups as my lettering system is not as straight forward as the original example (the letters are shifts on a schedule which is why morning shifts can't follow evening or overnight shifts for the same person)
    I also have a couple of 2 letter shifts N2 and F2. F2 can't be followed by any of the morning shifts including F, and N2 can't be followed by any shifts except N, M, and N2.
    Morning shifts D, Z, G, B, F Q: Evening shifts A, U, T, P E, H: Night shifts N, M, N2: afternoon through evening shift F2

    I ended up using 3 conditional formatting statements based on Phuocam's suggestion.

    Since N2 is a night shift I modified the original formula to
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    To cover night shifts not being followed by evening shifts either
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    And to cover the shifts that can't follow F2 which includes F
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Not sure if there is anyway to combine these statements.
    I tried using an array but got an error that it couldn't be used in CF.

    Thanks again,
    Stuart

+ 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. Conditional formatting gradient based on frequency of text entries
    By geobeck in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-09-2018, 01:52 PM
  2. [SOLVED] Conditional Formatting on column based on multiple Text criteria
    By Rellsunn in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-22-2017, 12:38 PM
  3. Conditional Formatting Based on Multiple Text Values
    By Butman in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 03-19-2014, 11:57 PM
  4. Conditional formatting based on multiple text criteria
    By tanyaslater in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-01-2014, 10:27 PM
  5. Formula for conditional formatting based on any of multiple text strings?
    By klenatron in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-28-2013, 03:31 PM
  6. [SOLVED] Simplifying Conditional Formatting - Formula Assistance Please
    By xkittenxx in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-19-2012, 08:57 PM
  7. Simplifying a Conditional Formatting Statement
    By ChemistB in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-03-2007, 03:43 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