In this tutorial I will show you how to use the Excel Logical functions such as IF, AND and OR. They are super useful if you need to calculate some values based on some logical criteria.
For example you only want a field to show you a number when another field is bigger than a specific value. In the following I’ll teach you how to do this:
IF
Function
If you need to check whether a condition is met in one of your workbooks then use Excel’s IF
Function.
The IF function checks whether a condition is met and returns a specific value you select when it’s true, and another one when it’s false. Note that you can choose which values are returned by Excel.
Insert the following function in your Excel workbook:
=IF(A1>5,"Correct","Incorrect")
Excel will now check whether the value of cell A1 is greater than 5 and will return Correct if it’s true and Incorrect if it’s false in the cell where you inserted the IF
Function.
Note that the IF
Function returns Correct because the value in cell A1 is greater than 5.
How to use the AND
Function
If you need to check whether multiple conditions are met in your Excel workbook then use the AND
Function. The AND
Function returns TRUE
if all criteria are met and FALSE
if any one of multiple criteria is not met.
Insert the following function in your Excel workbook:
=IF(AND(A1>5,B1>20), "Correct","Incorrect")
Excel will now check whether the value of cell A1 is greater than 5 the value of cell B1 is greater than 20. If both conditions are true, Excel will return Correct and if any of them is false Excel will return Incorrect in the cell where you inserted the IF
Function.
Note that the AND
Function returns FALSE
since the value in cell B1 is not higher than 20.
How to use the OR
function in Excel
If you need to check whether one of several conditions is met in your Excel workbook then use the OR
Function. The OR
Function returns TRUE
if any of several conditions is met and FALSE
if none of the conditions are met.
Insert the following formula in your Excel workbook:
=IF(OR(A1>5,B1>20),"Correct","Incorrect")
Excel will now check if the value of cell A1 is greater than 5, if the value of cell B1 is greater than 20, or if both conditions are met. If either one or both are true, then Excel will return Correct while it will return Incorrect in the cell where you inserted the IF
Function in case none of the criteria are met.
The OR
Function returns TRUE
since the value in cell A1 is greater than 5.
To show how powerful this can be, know that you can use AND
and OR
functions to check up to 255 conditions simultaneously.
That’s it for logical functions in Excel. I hope that this tutorials was helpful in explaining the concepts of logical functions in Excel to you.
Can you tell me in the comments if and how you’re using one of the IF, AND, or OR functions already? I’d love to learn what you do.