Search code examples
excelif-statementexcel-formulaexcel-2010excel-2007

How to use OR statement on multiple columns in Excel?


I have four variables in my excel sheet:

  1. Geyser
  2. Heater
  3. Ac
  4. Air cooler

I am creating a new variable in Excel sheet geyser/heater/ac/aircooler which is the combination of all these four variables. If there is a Yes in any one of the above-mentioned columns than the newly created variables should also have "Yes" otherwise it should be blank.

I know how to do that using IF and OR statement for two columns but I don't know how to use it for Four columns.enter image description here


Solution

  • If you have the latest version of Excel, you can use this:

    =IF(OR(A1:D1="Yes"),"Yes","No")
    

    enter image description here

    Include one OR argument per contiguous range. In case column C is not included:

    =IF(OR(A1:B1="Yes",D1:E1="Yes"),"Yes","No")
    

    For older versions,

    =IF(COUNTIF(A1:D1,"Yes")>0,"Yes","No")