+ Reply to Thread
Results 1 to 11 of 11

Flagging cells with values are a certain percentage off from values in surrounding cells

  1. #1
    Registered User
    Join Date
    02-20-2014
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    32

    Flagging cells with values are a certain percentage off from values in surrounding cells

    if I have a row of values:

    example:

    22.9 7.0 24.0 27.1 8.0 24.0 13.0 17.0 5.0 37.0 9.0 19.0 42.0


    What would be the best way to "flag" any of the values that are, say, >=20% different than the value in the cell to the left or right?

    Thanks in advance for any help! It is greatly appreciated!

  2. #2
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    170

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    Say your values are in row 1, you could use the following formula in conditional formatting:

    =IF(OR(B1+(B1*$B$4)<A1,(B1*$B$4)+B1<C1,B1-(B1*$B$4)>A1,B1-(B1*$B$4)>C1),TRUE), where $B$4 is the percentage difference you want to use.

    I have attached a sheet showing how that formula returns TRUE/FALSE for the conditional formatting. It won't work on your first or last values though; I can look at a workaround that will include the first and last values as well if you need it.
    Attached Files Attached Files

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    Maybe this, using cff's workbook...
    =OR(B1/A1>=1+$B$4,B1/C1>=1+$B$4)

    Note, you dont need the IF() component, you can just use...
    =OR(B1+(B1*$B$4)<A1,(B1*$B$4)+B1<C1,B1-(B1*$B$4)>A1,B1-(B1*$B$4)>C1)
    CF works on TRUE or FALSE, so that condition is either TRUE, (rule triggers) or it's not - FALSE or ERROR (rule does not trigger)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    170

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    Very clever!

    Slight amendment to your formula:

    =OR(B1/A1>=1+$B$4,B1<A1<=1-$B$4,B1/C1>=1+$B$4,B1<C1<=1-$B$4)

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    Thanks for the feedback (in a freaky good way lol)

    I saw you included a test both ways, but I read the OP request of ">=20% different than" as the cell being greater than or = to the cells either side of it...

    6...10...6
    10 is more than 20% greater than either side

    9...10...13
    10 is not greater than either cell

    hmmm now here's a question. Assuming I have understood correctly, 10 would get highlighted in the 1st example, but not the 2nd. But what about this 1?
    9...10...6
    10 is not greater than the left cell, but is greater than the right cell

  6. #6
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    170

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    I assumed he meant the difference had to be >=20%, regardless of which direction that difference was.

    OP?

  7. #7
    Registered User
    Join Date
    02-20-2014
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    32

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    Apologies. Need to better clarify my problem.

    If I have the following set of #'s, how can I flag a value in a cell if it is more than 20% different than the value in the cell only to the left of it (i.e., if B1 >= or 20% (+ or -)change from the value in A1, if C1 >= 20% (+ or -) change from the value in B1, etc)
    Example:

    22.9 7.0 24.0 27.1 8.0 24.0 13.0 17.0 5.0 37.0 9.0 19.0 42.0


    In the set of numbers above, I would expect 7.0, 24.0, 8.0, 24.0, etc to be highlighted.

    It sounds like condition formatting is exactly what i need

    Thanks!!!
    Last edited by Bigred25; 02-21-2014 at 11:15 AM.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    Did you try the suggestion in post # 4?
    =OR(B1/A1>=1+$B$4,B1<A1<=1-$B$4,B1/C1>=1+$B$4,B1<C1<=1-$B$4)

  9. #9
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    170

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    If it's only in the cell to the left, it makes the formula much simpler:

    =OR(B1*1.2>A1,B1*0.8<A1)

    Alternatively, you can use a cell reference to specify the margin of difference you want (say you want to change from 20% to 25%).

    In that case, assuming that the margin of difference you want is in cell B4, as in my previous workbook example, use this formula:

    =OR(B1*(1+$B$4)>A1,B1*(1-$B$4)<A1)

    Use that formula for the conditional formatting of cell B1, then use the format painter to paint it across the whole row.

  10. #10
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    170

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    Whoops! I got my signs around the wrong way. I've had a coffee now, let's try this again.

    =OR(B1*(1+$B$4)<A1,B1*(1-$B$4)>A1)

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Flagging cells with values are a certain percentage off from values in surrounding cel

    This thread is marked solved, but it seems that it is not yet complete?

+ 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: 1
    Last Post: 09-04-2012, 05:49 AM
  2. Replies: 2
    Last Post: 05-02-2012, 08:38 PM
  3. Trying to increase values by a percentage in cells with more than one value
    By scarfo43 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2012, 04:25 PM
  4. Replies: 0
    Last Post: 01-09-2012, 03:51 PM
  5. Replies: 3
    Last Post: 07-16-2011, 11:33 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