Using IF with AND, OR, and NOT functions in Excel (2024)

In Excel, the IF function allows you to make a logical comparison between a value and what you expect by testing for a condition and returning a result if that condition is True or False.

  • =IF(Something is True, then do something, otherwise do something else)

But what if you need to test multiple conditions, where let’s say all conditions need to be True or False (AND), or only one condition needs to be True or False (OR), or if you want to check if a condition does NOT meet your criteria? All 3 functions can be used on their own, but it’s much more common to see them paired with IF functions.

Use the IF function along with AND, OR and NOT to perform multiple evaluations if conditions are True or False.

Syntax

Argument name

Description

logical_test (required)

The condition you want to test.

value_if_true (required)

The value that you want returned if the result of logical_test is TRUE.

value_if_false (optional)

The value that you want returned if the result of logical_test is FALSE.

Here are overviews of how to structure AND, OR and NOT functions individually. When you combine each one of them with an IF statement, they read like this:

  • AND – =IF(AND(Something is True, Something else is True), Value if True, Value if False)

  • OR – =IF(OR(Something is True, Something else is True), Value if True, Value if False)

  • NOT – =IF(NOT(Something is True), Value if True, Value if False)

Examples

Following are examples of some common nested IF(AND()), IF(OR()) and IF(NOT()) statements in Excel. The AND and OR functions can support up to 255 individual conditions, but it’s not good practice to use more than a few because complex, nested formulas can get very difficult to build, test and maintain. The NOT function only takes one condition.

Using IF with AND, OR, and NOT functions in Excel (1)

Here are the formulas spelled out according to their logic:

Formula

Description

=IF(AND(A2>0,B2<100),TRUE, FALSE)

IF A2 (25) is greater than 0, AND B2 (75) is less than 100, then return TRUE, otherwise return FALSE. In this case both conditions are true, so TRUE is returned.

=IF(AND(A3="Red",B3="Green"),TRUE,FALSE)

If A3 (“Blue”) = “Red”, AND B3 (“Green”) equals “Green” then return TRUE, otherwise return FALSE. In this case only the first condition is true, so FALSE is returned.

=IF(OR(A4>0,B4<50),TRUE, FALSE)

IF A4 (25) is greater than 0, OR B4 (75) is less than 50, then return TRUE, otherwise return FALSE. In this case, only the first condition is TRUE, but since OR only requires one argument to be true the formula returns TRUE.

=IF(OR(A5="Red",B5="Green"),TRUE,FALSE)

IF A5 (“Blue”) equals “Red”, OR B5 (“Green”) equals “Green” then return TRUE, otherwise return FALSE. In this case, the second argument is True, so the formula returns TRUE.

=IF(NOT(A6>50),TRUE,FALSE)

IF A6 (25) is NOT greater than 50, then return TRUE, otherwise return FALSE. In this case 25 is not greater than 50, so the formula returns TRUE.

=IF(NOT(A7="Red"),TRUE,FALSE)

IF A7 (“Blue”) is NOT equal to “Red”, then return TRUE, otherwise return FALSE.

Note that all of the examples have a closing parenthesis after their respective conditions are entered. The remaining True/False arguments are then left as part of the outer IF statement. You can also substitute Text or Numeric values for the TRUE/FALSE values to be returned in the examples.

Here are some examples of using AND, OR and NOT to evaluate dates.

Using IF with AND, OR, and NOT functions in Excel (2)

Here are the formulas spelled out according to their logic:

Formula

Description

=IF(A2>B2,TRUE,FALSE)

IF A2 is greater than B2, return TRUE, otherwise return FALSE. 03/12/14 is greater than 01/01/14, so the formula returns TRUE.

=IF(AND(A3>B2,A3<C2),TRUE,FALSE)

IF A3 is greater than B2 AND A3 is less than C2, return TRUE, otherwise return FALSE. In this case both arguments are true, so the formula returns TRUE.

=IF(OR(A4>B2,A4<B2+60),TRUE,FALSE)

IF A4 is greater than B2 OR A4 is less than B2 + 60, return TRUE, otherwise return FALSE. In this case the first argument is true, but the second is false. Since OR only needs one of the arguments to be true, the formula returns TRUE. If you use the Evaluate Formula Wizard from the Formula tab you'll see how Excel evaluates the formula.

=IF(NOT(A5>B2),TRUE,FALSE)

IF A5 is not greater than B2, then return TRUE, otherwise return FALSE. In this case, A5 is greater than B2, so the formula returns FALSE.

Using IF with AND, OR, and NOT functions in Excel (3)

Using AND, OR and NOT with Conditional Formatting in Excel

In Excel, you can also use AND, OR and NOT to set Conditional Formatting criteria with the formula option. When you do this you can omit the IF function and use AND, OR and NOT on their own.

In Excel, from the Home tab, click Conditional Formatting > New Rule. Next, select the “Use a formula to determine which cells to format” option, enter your formula and apply the format of your choice.

Using IF with AND, OR, and NOT functions in Excel (4)

Using the earlier Dates example, here is what the formulas would be.

Using IF with AND, OR, and NOT functions in Excel (5)

Formula

Description

=A2>B2

If A2 is greater than B2, format the cell, otherwise do nothing.

=AND(A3>B2,A3<C2)

If A3 is greater than B2 AND A3 is less than C2, format the cell, otherwise do nothing.

=OR(A4>B2,A4<B2+60)

If A4 is greater than B2 OR A4 is less than B2 plus 60 (days), then format the cell, otherwise do nothing.

=NOT(A5>B2)

If A5 is NOT greater than B2, format the cell, otherwise do nothing. In this case A5 is greater than B2, so the result will return FALSE. If you were to change the formula to =NOT(B2>A5) it would return TRUE and the cell would be formatted.

Note:A common error is to enter your formula into Conditional Formatting without the equals sign (=). If you do this you’ll see that the Conditional Formatting dialog will add the equals sign and quotes to the formula - ="OR(A4>B2,A4<B2+60)", so you’ll need to remove the quotes before the formula will respond properly.

Need more help?

See also

You can always ask an expert in the Excel Tech Communityor get support inCommunities.

Learn how to use nested functions in a formula

IF function

AND function

OR function

NOT function

Overview of formulas in Excel

How to avoid broken formulas

Detect errors in formulas

Keyboard shortcuts in Excel

Logical functions (reference)

Excel functions (alphabetical)

Excel functions (by category)

Using IF with AND, OR, and NOT functions in Excel (2024)
Top Articles
Syd's Life - Syd Barrett
The real Syd Barrett – by the people who knew him
It's Official: Sabrina Carpenter's Bangs Are Taking Over TikTok
Dte Outage Map Woodhaven
PRISMA Technik 7-10 Baden-Württemberg
Merlot Aero Crew Portal
Waive Upgrade Fee
MADRID BALANZA, MªJ., y VIZCAÍNO SÁNCHEZ, J., 2008, "Collares de época bizantina procedentes de la necrópolis oriental de Carthago Spartaria", Verdolay, nº10, p.173-196.
Heska Ulite
Hardly Antonyms
Wildflower1967
O'reilly's Auto Parts Closest To My Location
Think Up Elar Level 5 Answer Key Pdf
Hijab Hookup Trendy
Dutchess Cleaners Boardman Ohio
Craigslist Mpls Cars And Trucks
Youravon Comcom
Brett Cooper Wikifeet
Illinois VIN Check and Lookup
Roof Top Snipers Unblocked
Craigslist In Visalia California
Jang Urdu Today
Knock At The Cabin Showtimes Near Alamo Drafthouse Raleigh
Hampton University Ministers Conference Registration
[PDF] PDF - Education Update - Free Download PDF
Acurafinancialservices Com Home Page
Shiny Flower Belinda
The Procurement Acronyms And Abbreviations That You Need To Know Short Forms Used In Procurement
Spy School Secrets - Canada's History
Mg Char Grill
Walter King Tut Johnson Sentenced
Craigslist In Myrtle Beach
Hotels Near New Life Plastic Surgery
Gwu Apps
Albertville Memorial Funeral Home Obituaries
Barber Gym Quantico Hours
Überblick zum Barotrauma - Überblick zum Barotrauma - MSD Manual Profi-Ausgabe
Indio Mall Eye Doctor
Weather Underground Cedar Rapids
Craigslist Odessa Midland Texas
Below Five Store Near Me
Former Employees
Tattoo Shops In Ocean City Nj
Jamesbonchai
21 Alive Weather Team
Patricia And Aaron Toro
Dancing Bear - House Party! ID ? Brunette in hardcore action
Stephen Dilbeck, The First Hicks Baby: 5 Fast Facts You Need to Know
Assignation en paiement ou injonction de payer ?
Ics 400 Test Answers 2022
2121 Gateway Point
683 Job Calls
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated:

Views: 6168

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.