+ Reply to Thread
Results 1 to 11 of 11

Conditional Formatting - If three cells are equal but not 0

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    37

    Conditional Formatting - If three cells are equal but not 0

    Hello all,

    I have been making a spreadsheet to compare prices of a given item from three companies and show which item is cheapest. I have managed all the conditional formatting apart from a formula to show that two of three prices are the same when one cell has a zero in it.

    I have come up with the following formula, [ =AND(L2=H2,H2=F2,L2=J2,F2<>0,H2<>0,J2<>0)) ] but this only seems to work if there is a value in each cell. Is there a way for excel format this correctly?

    Many thanks,

    Per11

  2. #2
    Registered User
    Join Date
    01-25-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Conditional Formatting - If three cells are equal but not 0

    I have also noted that if two cells are equal and one is higher then it doesn't format either. Should the formulae be separated out?

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting - If three cells are equal but not 0

    You mention 3 cells in the thread title but your formula has 4 cells?

    L2, H2, F2 and J2

    Conditional Formatting
    Formula:

    =AND($L2<>"",$L2=MIN($L2,$H2,$F2,$J2))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: Conditional Formatting - If three cells are equal but not 0

    Do you have a sample file with this in it....
    As pointed out by Tony, your comments dont match your example. Beyond that I am not sure I understand the intent... You want to format a cell when they are all EQUAL but not 0?

    Tony, I am missing where or why you went to decide that L2 gets to be equal to the least value?

    =AND(L2<>"",L2<>0,L2=F2,L2=H2,L2=J2)
    By basing the entire condition on L we can dictate that L must not be 0 and equal to the rest of the set. This inherently makes the others equal to each other.

    To me that gets you to the results you are requesting... F H and J must all equal L where L cannot be empty or 0

    If this is not the goal then add a working example book with multiple rows showing different scenarios and something changing in color when the desired "TRUE" is hit
    -If you think you are done, Start over - ELeGault

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting - If three cells are equal but not 0

    Quote Originally Posted by ELeGault View Post
    Tony, I am missing where or why you went to decide that L2 gets to be equal to the least value?
    I may have misunderstood the requirement.

    I read this:

    show which item is cheapest
    To mean they want to highlight the min value.

  6. #6
    Registered User
    Join Date
    01-25-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Conditional Formatting - If three cells are equal but not 0

    Forgive me I could have made that clearer. L2 is the minimum number but zero of the given range as you will see from the attached workbook.

    The cheapest price can either be, L2=J2=H2=F2 or in the example shown, L2=H2=F2 and J3=0. Or a given combination of H2 or F2 =0. So presumably the formula will need to take this into account or the formulae should be separate but format the cell in the same way?

    I hope this was helpful.
    Attached Files Attached Files
    Last edited by per11; 08-22-2016 at 08:11 AM.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting - If three cells are equal but not 0

    Sorry, I downloaded your file but I have no idea what you're wanting to do!

  8. #8
    Registered User
    Join Date
    01-25-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Conditional Formatting - If three cells are equal but not 0

    Sorry, I will try again! (I have swapped the sheet with a different with all the conditionally formatted rules to make it easier).

    L2 is the minimum price of the three given cells. This price could be the lowest price from one provider and this is formatted correctly at the moment.

    However the price might be the same from two or three of the sellers. To complicate matters further, one of the cells might be a zero whilst the two other prices are equal.

    I hope this makes it clearer.

    Per11.
    Last edited by per11; 08-22-2016 at 08:33 AM.

  9. #9
    Registered User
    Join Date
    01-25-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Conditional Formatting - If three cells are equal but not 0

    Thanks for all your help. I have worked out what I was trying to do and to demonstrate this I have uploaded a simpler version of the completed spreadsheet.

    First I created a circular argument if all the cells are equal and I used the formula, =AND(L2=F2,F2=H2,H2=J2,J2=L2) and this returns a fill for the cell if this is true. This formula must be at the bottom of the list to make sure this is processed last.

    Then I worked out what every possible combination of the cells could be, bearing in mind that L2 is always stable given the formula in the cell. Therefore, the combinations for the formatting are:

    L2=F2=H2 less than J2
    L2=F2=J2 less than H2
    L2=H2=J2 less than F2

    Then you use an "and" function to determine the possible combinations. The standard one in this instance is, =AND(L2=Cell1,Cell1=Cell2,Cell2 less than Cell3 . Therefore the possible combinations are:

    =AND(L2=F2,F2=H2,H2 less than J2)
    =AND(L2=F2,F2=J2,J2 less than H2)
    =AND(L2=H2,H2=J2,J2 less than F2)

    (N.B. It would not let me us shift , so that should be the the "less than" should be the less than sign)

    And then conditional formatting does the rest. Although this way of doing things, you end up with a lot of formulae, which may not be helpful to some.

    I hope that this is a lot clearer then when we started! If the community would find it useful I can release the whole formatted spread sheet?

    Thanks again,

    PER11
    Attached Files Attached Files
    Last edited by per11; 08-22-2016 at 07:00 PM.

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Conditional Formatting - If three cells are equal but not 0

    referring to l2 is unnecessary in your example and may cause your circular referencing

    you have 7 scenarios from what i can see
    1,2 or 3 lowest
    1-2 match
    2-3 match
    1-3 match
    all 3 match

    this formula will extract 1-7 out for you of which you can conditional format all 7 outcomes
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ps 1-3 returns as text
    Attached Files Attached Files
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  11. #11
    Registered User
    Join Date
    01-25-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Conditional Formatting - If three cells are equal but not 0

    @humdingaling thanks for the help! It is very much appreciated.

+ 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 - If three cells are equal
    By per11 in forum Excel General
    Replies: 8
    Last Post: 08-23-2016, 02:09 PM
  2. Replies: 5
    Last Post: 06-25-2015, 12:05 PM
  3. [SOLVED] Conditional Formatting Formula - Chang color of cells is other cell is equal to..
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 6
    Last Post: 09-29-2013, 11:00 PM
  4. [SOLVED] Conditional formatting if equal or greater than average in the range of cells
    By Abu Abdurakhim in forum Excel General
    Replies: 7
    Last Post: 05-28-2013, 10:01 AM
  5. Conditional Formatting - not equal to
    By lordtopcat in forum Excel General
    Replies: 1
    Last Post: 08-09-2011, 11:34 PM
  6. Conditional formatting - nothing does not equal zero
    By username132 in forum Excel General
    Replies: 4
    Last Post: 03-10-2008, 05:37 AM
  7. DOES NOT EQUAL - Conditional Formatting
    By SamuelT in forum Excel General
    Replies: 5
    Last Post: 02-09-2006, 10:09 AM

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