+ Reply to Thread
Results 1 to 12 of 12

problem with logical formula for conditional formatting

  1. #1
    Registered User
    Join Date
    06-01-2012
    Location
    Swarthmore, PA, USA
    MS-Off Ver
    Excel:mac 2011
    Posts
    14

    problem with logical formula for conditional formatting

    Hello everyone,

    Just had a question on here but already I'm stumped again. I'm using conditional formatting to shade entire rows based on the text a given row contains in the E column. If "cash" is anywhere in the E column for that row the whole row turns yellow and if "check" is anywhere in the E column for that row the whole row turns green. Now I simply want all rows that aren't green or yellow to turn red. I was attempting to do this by negating what I used to achieve the yellow and green shading. For those I used =SEARCH("whatever",$E18) where whatever was really cash or check for the conditional formatting formula. For this, I was attempting to use =NOT(SEARCH(OR("cash","check"),$E18)). My thought was that if SEARCH found cash or check in that line it would return TRUE and then the NOT would negate it for so those lines would not be shaded, and if SEARCH didn't find cash or check in that cell then it would return a FALSE that would be negated by the not and so would be shaded. What am I missing?

    Thanks again in advance.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: problem with logical formula for conditional formatting

    SEARCH actually returns a number or an error, so you can use COUNT to see whether either SEARCH is successful (zero means neither is successful), so try

    =COUNT(SEARCH("cash",$E18),SEARCH("check",$E18))=0
    Audere est facere

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

    Re: problem with logical formula for conditional formatting

    A couple of things....
    1. In conditional formatting it won't accept SEARCH(OR("cash","check"),E18. You'd need to separate them into two separate SEARCHES with the OR in front.
    2. Because you will be returning an error when the search finds nothing, that will screw up your OR statement too. You'll need to put your search inside an ISNUMBER.

    Soooo, try
    =NOT(OR(ISNUMBER(SEARCH("cash",$E18)),ISNUMBER(SEARCH("check",$E18))))
    Does that work for you?

    Or used DaddyLonglegs solution. Much nicer!
    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
    Registered User
    Join Date
    06-01-2012
    Location
    Swarthmore, PA, USA
    MS-Off Ver
    Excel:mac 2011
    Posts
    14

    Re: problem with logical formula for conditional formatting

    So both of these actually turn stuff red (which is a first for this sheet), but both also turn things red that shouldn't be (things with just "cash" or "check" in the E column for that row) and don't turn everything red that should be red (misses some random rows that don't have "cash" or "check" in the E column).

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: problem with logical formula for conditional formatting

    Works for me.....

    ...I copied your cell reference E18 but that would only be appropriate if your data begins at row 18, if data starts on another row you should adjust the formula ccordingly

  6. #6
    Registered User
    Join Date
    06-01-2012
    Location
    Swarthmore, PA, USA
    MS-Off Ver
    Excel:mac 2011
    Posts
    14

    Re: problem with logical formula for conditional formatting

    Both of your posted solutions shade the same rows red (hmmmmmmmm...) but many of the rows they shade were green or yellow before (i.e. had only "cash" or "check" in the E column for that row) and it misses some random cells on my sheet as well... keep in mind that this is the third conditional formatting formula applied to the same range of cells, I'm not sure if that is affecting anything. I'd like to attach the sheet but unfortunately I can't (NDA's).

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: problem with logical formula for conditional formatting

    See attached example.

    I used the range A2:J12 and because of that the formulas used apply to the first row of that range, i.e. row 2 so I used these three formulas

    =SEARCH("cash",$E2) - yellow
    =SEARCH("check",$E2) - green
    =COUNT(SEARCH("cash",$E2),SEARCH("check",$E2))=0 - red

    works as expected, I think
    Attached Files Attached Files

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

    Re: problem with logical formula for conditional formatting

    Are you entering it just like the formula and is E18 the first cell in your range?

    Might be a MAC thing. I'm attaching a spreadsheet. My formula is used in Col E and DDL's is in Col G. Both are working on my computer.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-01-2012
    Location
    Swarthmore, PA, USA
    MS-Off Ver
    Excel:mac 2011
    Posts
    14

    Re: problem with logical formula for conditional formatting

    I just tried: AND(NOT(ISNUMBER(SEARCH("check",$E18))),NOT(ISNUMBER(SEARCH("cash",$E18)))

    which is very similar to what ChemistB did and the same rows got shaded red... but those rows still include many that only have "check" in the E column. Quite confused as to why that is the case... some random rows that had nothing in the E column also did not get shaded while a lot of them did.

  10. #10
    Registered User
    Join Date
    06-01-2012
    Location
    Swarthmore, PA, USA
    MS-Off Ver
    Excel:mac 2011
    Posts
    14

    Re: problem with logical formula for conditional formatting

    Both your solutions work on the sheets you attached, neither work in my sheet that does have E18 as the first cell in the range. I must be doing something really stupid to throw it off? I am just gonna attach the sheet quick (with most of the stuff pasted over by an unrelated soccer spreadsheet, yet still with the same problem).academy_reserves_index.xlsx

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: problem with logical formula for conditional formatting

    Yes, you had the "applies to" range set differently for the red formatting. I changed that to encompass rows 18 to 105 as per your other conditions.....but that then messed up the references in the formula so I re-entered as it should be, i.e.

    =COUNT(SEARCH("cash",$E18),SEARCH("check",$E18))=0

    Now it works OK, I think

    Note: if you just want to have all rows red that are not yellow or green it could be easier to use normal formatting to colour those red with the green and yellow formatting only provided by conditional formatting......
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    06-01-2012
    Location
    Swarthmore, PA, USA
    MS-Off Ver
    Excel:mac 2011
    Posts
    14

    Re: problem with logical formula for conditional formatting

    YES! So that was it, every time I would enter in the formula and then change the "applies to" range afterwards, never checking the cell references for the formula again.

    Thanks very much to both of you for your help and patience.

+ 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