Search code examples
excelexcel-formulaworksheet-functionexcel-2013countif

COUNTIF with OR Statement


I'm trying to count the number of times two statements occur. The problem is that if the first statement occurs then it won't check for the second.

Maybe if easier if I explain like this:

If statement1= true then
  count = 1 and move next
else
  if statement2= true 
    count = 1 and move next
  end if
end if

I'm using this but can't seem to get the OR segment working:

=COUNT.if((E:E;">120";E:E;"<139")OR(F:F;">80";F:F;"<89"))

Solution

  • Ugly, but might suit:

    =COUNTIFS(E:E;">120";E:E;"<139")+COUNTIFS(F:F;">80";F:F;"<89")-COUNTIFS(E:E;">120";E:E;"<139";F:F;">80";F:F;"<89")  
    

    Counts all the applicable instances in ColumnE, adds the count of all the applicable instances in ColumnF then subtracts the instances where both ColumnE and ColumnF are within the respective bounds - this last part might not be required.

    An array formula might be more elegant but for entire columns rather slow.