FormulaCraft

How to combine IF and OR in Excel and Google Sheets

Topic:IF, IFS & nested conditions
Excel & Google Sheets
=IF(OR(A2="Red",A2="Blue"),"Primary","Other")

Verified example

Computed by a real spreadsheet engine on the sample data below.

ColorCategory
Red
Green
Blue
Yellow

=IF(OR(A2="Red",A2="Blue"),"Primary","Other")Primary

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1List all conditions where any one being true should trigger the result, inside OR(): OR(condition1, condition2, …).
  2. 2Use OR() as the logical_test of IF: =IF(OR(A2="Red",A2="Blue"),"Primary","Other").
  3. 3Press Enter. The formula returns the true value if any condition in OR is TRUE; otherwise it returns the else value.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

Can I combine AND and OR in the same IF formula?

Yes: =IF(AND(A2>0,OR(B2="Yes",B2="Maybe")),"OK","No") tests that A2 is positive AND that B2 is either Yes or Maybe.

Is there a limit to how many OR conditions I can have?

OR accepts up to 255 logical conditions.

More on IF, IFS & nested conditions

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: