Logical test

A logical test in Excel (logical expression) returns only two types of values: TRUE or FALSE, which helps in decision-making processes.

What is a logical test?

A logical test in Excel compares two values or expressions that result in TRUE or FALSE. For example, you can check if a value is greater than another (=A1 > B1), or if two values are equal (=A1 = B1). Logical tests are often used in functions like IF to trigger different actions based on whether the test is TRUE or FALSE.

If you want to test that cell B3 is equal to the string “Product”, use the following formula:

=B3=”Product”

simple-logical-test-TRUE-or-FALSE

The formula has two outputs: TRUE or FALSE.

Steps to create a logical test in Excel

  1. Type an equal sign (=)
  2. Enter the first value or use a cell reference
  3. Select a logical symbol that you want to use for comparison
  4. Select the cell that contains the second value

That’s all.

Logical operators

List of the logical operators:

  • = equal to
  • > greater than
  • >= greater than or equal to
  • < less than
  • <= less than or equal to
  • <> not equal

Sometimes, we use multiple logical tests in Excel formulas. Depending on your task, your formula may contain different logical tests. For example, to test if cell B8 is greater than 10 AND less than 20, you can use a formula: =AND(B8>10, B8<20).

In this case, the formula returns TRUE or FALSE also.

Let’s see a practical example of how to use logical operators. A logical test is important when using conditional formatting to highlight cells or ranges. In the example below, you want to highlight cells based on criteria. If the value in a range is greater than 40, apply the green fill.

conditional-formatting-logical-test

All logical tests work based on Boolean logic.

Additional resources: