Search code examples
excelexcel-formulaexcel-2010

How to check whether the current value of a cell is within a certain value of all previous cells


I wanted to inquire if there was a formula that could check whether the current cell is within 12 (above or below) all previous cells and exclude if this is true. For example

enter image description here

In the picture above the 3rd row (value of 4874) is less than 12 away from the 1st row value (4875) so is excluded.

All formulas i have seen so far seem to utilise max or min functions but im not sure if that is applicable in this case.

Any help would be appreciated. Thanks!


Solution

  • Countifs is available in Excel-2010 so you can use this starting in A3:

    =IF(COUNTIFS(A$2:A2,"<=A3",A$2:A2,">="&A3-12)+
    COUNTIFS(A$2:A2,">="&A3,A$2:A2,"<="&A3+12),"Exclude","Include")
    

    enter image description here