Excel's IF statement made easy

Though abbreviated, the logic functions in Excel are no harder than any other



Excel is many things: powerful, useful, colorful, handy, but its logic functions can be challenging to newcomers due to their implied logic, and a shorthand syntax designed to fit on a single line in the formula bar.

In particular, there’s the IF statement, which generates by far the most Excel-related queries to Answer Line. But once you’re familiar with it, it’s a breeze. At least for simple stuff.

Just like ordering lunch

Logic in programming or formulas is no different from deciding where to go and what to eat for lunch. If Harry’s is open, then we’ll go there, and I’ll have the Caesar’s salad. If Harry’s is closed, then let’s eat at Harriet’s and there’s a turkey burger that’s not too heavy. If both are closed, to heck with it, I’m doubling down on a Whopper meal.

In a formula that’s more relevant to Excel: If this cell, A1, is equal to 1, then cell B1 will equal 2, otherwise cell B1 will equal 3. Plain language requires a lot of typing and space, so it’s common practice to both infer and shorthand. In the BASIC programming language (not VBA, though it’s similar) the logic above would look something like:

IF A1 = 1 THEN

B1 = 2


B1 = 3


As the word “will” and others can be deduced from context, they are left out. “Equals” has been short-handed to the = symbol. Fewer words to type, while still easily readable.

Excel condenses things even further. The destination, being the cell the formula is entered into, is also inferred by shorthanding. The “=" you must enter into the formula bar before creating a formula simply means "this cell equals the result of the following formula”. The true and false results are identified merely by their order, as the second and third fields, respectively.

What you wind up with is =IF(the Comparison to make, the value of the cell if the comparison is true, the value of the cell if the comparison is false). Or specifically in this case: =IF(A1=1, 2, 3). Nice, neat, compact—if not particularly easy for neophytes.


Things get even harder to read when you want to do one thing if A1 equals 1, and another if A1 equals 13. If the first test isn’t true, i.e., A1 does not equal 1, the formula falls through to the false field. So cleverly, instead of forcing you to return a hard value such as 3, Excel lets you use this false field to test another condition using a nested IF statement. In this case, if A1 is equal to 13: =IF(A1=1, B1=2, IF(A1=13, B1=5, B1=3)).

The last false field in a series of nested IF statements is always the default result returned if none of the conditions are met.

You can also nest IF statements in the true field if you want to test if multiple conditions are true, such as B1 =2 and C1 = 3, though there are other functions that are easier such as AND or OR, which I’ll cover in another column. You can continue to nest IF statements in either field till the cows come home, or, more likely—the formula becomes impossible to read, which happens very quickly. If you want to make complex logic more readable, then you’ll have to delve into Visual Basic for Applications (VBA) and write macros for cells.

Excel provides other powerful, IF-related functions such as COUNTIFS and SUMIFS, and AVERAGEIFS that make it easier to deal with ranges of cells, but they all operate in the same manner.

By the way, the mock Excel formula for lunch would be (more or less): =IF(Harrys=Open, “Caesar’s salad”, IF(Harriets=Open, “Turkey burger”, “Burger King Whopper Meal times two”)).

More stuff

That’s it for this time. Next time, I’ll cover the logical operators beyond the equals (=) I covered here, including “greater than” (>), less than (<), etc.

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection

Tags ExcelMicrosoftmicrosoft office

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Jon L. Jacobi

PC World (US online)
Show Comments



Victorinox Werks Professional Executive 17 Laptop Case

Learn more >

Sansai 6-Outlet Power Board + 4-Port USB Charging Station

Learn more >



Back To Business Guide

Click for more ›

Most Popular Reviews

Latest Articles


PCW Evaluation Team

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?