+ Reply to Thread
Results 1 to 7 of 7

Conditional Formatting with Formula - have I got the order of precedence wrong?

  1. #1
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    810

    Conditional Formatting with Formula - have I got the order of precedence wrong?

    Hi,

    I have set up the attached sample data to test my understanding of conditional formatting (CF).

    The required cell fill colours are shown in column A, the associated CF conditions in column B and the values to be thus formatted in column C.

    I seem to have set up the correct formulae for the CF but all results in column C are formatted as if they're <-0.50, which only one is.

    Can someone please tell me what I'm doing wrong?

    Thanks!
    Attached Files Attached Files
    Last edited by andrewc; 07-05-2019 at 02:53 PM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Conditional Formatting with Formula - have I got the order of precedence wrong?

    You formulae should be like
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    otherwise you are only looking at C2

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Conditional Formatting with Formula - have I got the order of precedence wrong?

    Red =$C2<-0.5
    Amber =AND($C2>=-0.5,$C2<=0.5)
    Green =AND($C2>0.5,$C2<>"n/a")
    ---------------
    =$C$2:$C$5>0.5 is only looking at the first cell in the range but applying that condition to every cell in the range.
    Last edited by protonLeah; 07-05-2019 at 02:43 PM.
    Ben Van Johnson

  4. #4
    Forum Contributor
    Join Date
    02-08-2005
    MS-Off Ver
    Microsoft 365
    Posts
    810

    Re: Conditional Formatting with Formula - have I got the order of precedence wrong?

    Thank you!

  5. #5
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Conditional Formatting with Formula - have I got the order of precedence wrong?

    As the others have said, you just need to refer to the top-left cell of the range you're trying to format. Excel will apply the formula as you enter it to this top-left cell. It will then, in the background, alter the row and/or column it is looking at to the next cell down / across, unless you lock the reference by using the $ sign.

    So, let's say you want to CF the range C2:D4. You put in the formula =C2<0.5 - with red fill. Excel looks at C2 and checks if it is <0.5 - if so it fills C2 red. Then it looks at C3 and uses the formula =C3<0.5 (you don't see this, it happens in the background) and so on until it gets to D4 where it uses =D4<0.5 and formats appropriately.

    If you were to use =$C2<0.5 then when it moves on to column D it will still look at column C (so using =C2<0.5 for cell D2). Similarly if you used =C$2<0.5 it would always look at row 2 (so using =C2<0.5 for cell C4). If you use $ signs for both, it will always look at the figure in that single cell to format the entire range.

    Hope that makes sense, sorry for the long post.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,084

    Re: Conditional Formatting with Formula - have I got the order of precedence wrong?

    You're welcome & thanks for the feedback

  7. #7
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Conditional Formatting with Formula - have I got the order of precedence wrong?

    Glad we could help and thanks for the rep.

+ 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: 3
    Last Post: 07-05-2019, 11:06 AM
  2. Conditional formatting precedence question
    By lamlam28 in forum Excel General
    Replies: 4
    Last Post: 01-27-2019, 11:50 PM
  3. [SOLVED] What's wrong with this formula for conditional formatting
    By MeijdenB1977 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 10-02-2018, 09:49 AM
  4. [SOLVED] Conditional formatting and precedence rules
    By KClem in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-25-2015, 02:42 PM
  5. MAJOR BUG: Excel operator precedence is wrong
    By P Keenan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-23-2006, 09:25 AM
  6. With formulas does anyone know the order of precedence BOMDAS
    By Samantha in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-14-2005, 04:48 AM
  7. Operator precedence (order of operate) =A1/A2*A3^5-(A1+A2)
    By Masood Shahab in forum Excel General
    Replies: 7
    Last Post: 09-08-2005, 10:05 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