How to Write an If Statement in Excel | Formula That Works

An Excel IF formula tests a condition and returns one result when true and another when false.

Excel’s IF function is one of those tools that feels tricky until the pattern clicks. Once it does, you can sort scores, label data, flag missing entries, and build worksheets that react on their own. The trick is not memorizing random formulas. It’s learning the structure and reading it in plain English.

A clean IF statement has three parts: a test, a result for true, and a result for false. That’s it. If you can say the rule out loud, you can usually write the formula.

Say you want a score in cell B2 to show “Pass” when it is 50 or more, and “Fail” when it is below 50. In plain speech, that rule sounds like this: if B2 is 50 or more, return Pass; else return Fail. Excel turns that into a formula.

What An Excel IF Statement Actually Does

The IF function checks whether something is true or false. Excel then gives back one value for the true side and another for the false side. Microsoft’s IF function documentation describes this as a logical comparison with two possible results.

The Basic Pattern

The standard structure looks like this:

=IF(logical_test, value_if_true, value_if_false)

Each part has a job:

  • logical_test: the rule Excel checks
  • value_if_true: what Excel returns when the rule passes
  • value_if_false: what Excel returns when the rule fails

How To Read It In Plain English

The fastest way to stop IF formulas from feeling messy is to read them like a sentence. Take this one:

=IF(A2>100,"Over Budget","Within Budget")

Read it as: if A2 is greater than 100, show “Over Budget”; else show “Within Budget.” Once you get used to that rhythm, writing formulas gets a lot easier.

Writing An Excel If Statement For Everyday Tasks

Most people use IF for the same handful of jobs: grading, labeling, checking blanks, and flagging values above or below a cutoff. Those cases are the best place to practice because the logic is easy to picture.

Use It For Numbers

If a score lives in C2 and you want a pass mark at 60, your formula can be:

=IF(C2>=60,"Pass","Fail")

This works well for test scores, sales targets, attendance goals, and budget checks. The formula stays the same. Only the cell and the rule change.

Use It For Text

IF can test words too. If D2 contains “Paid” and you want a note in another cell, you can write:

=IF(D2="Paid","Complete","Open")

Text needs quotation marks. If you skip them, Excel treats the word like a name or reference and throws an error.

Use It To Check Blanks

Blank checks are common in trackers and forms. A clean pattern is:

=IF(A2="","Missing","Filled")

That empty pair of quotes tells Excel to look for nothing in the cell. It’s a handy way to spot records that still need work.

Task Formula Pattern What It Returns
Pass or fail by score =IF(B2>=50,"Pass","Fail") Pass for 50 or more, Fail for less
Sales target met =IF(C2>=1000,"Hit","Miss") Hit when sales reach 1000
Mark late payment =IF(D2>TODAY(),"Not Due","Check") Shows whether the due date has passed
Label status text =IF(E2="Paid","Closed","Open") Closed for Paid, Open for anything else
Spot blanks =IF(A2="","Missing","Filled") Flags empty cells
Apply discount =IF(F2>=5,G2*0.9,G2) Discounted price for orders of 5 or more
Check positive or negative =IF(H2>0,"Positive","Zero Or Less") Simple sign check
Review stock level =IF(I2<10,"Reorder","OK") Reorder when stock drops below 10

How To Write An If Statement In Excel With Clean Syntax

The easiest way to build the formula is to write it in the same order every time. Start with the test. Then decide what should happen on the true side. Then fill in the false side. If you try to invent the formula from the middle, commas and brackets start going sideways.

A Simple Build Order

  1. Type =IF(
  2. Enter the rule, such as B2>=70
  3. Add a comma
  4. Enter the true result, such as "Pass"
  5. Add another comma
  6. Enter the false result, such as "Fail"
  7. Close with )

That gives you:

=IF(B2>=70,"Pass","Fail")

Common Errors That Break The Formula

Most IF errors come from a small handful of issues, not from the logic itself.

Missing Quotes Around Text

If the result is a word, wrap it in quotes. “Pass” works. Pass by itself does not.

Wrong Number Of Commas

IF needs three arguments. That means two commas in a standard formula. If one is missing, Excel can’t sort the pieces.

Mixed-Up Comparison Signs

> means greater than. < means less than. >= means greater than or equal to. A tiny sign slip can flip the result for every row.

Numbers Stored As Text

If Excel sees 100 as text instead of a number, your test may fail even when the value looks right. If results seem odd, check cell formatting and remove stray spaces.

When you need more than one condition, Excel lets you pair IF with logical functions. Microsoft shows this in its page on using IF with AND, OR, and NOT. That pattern is handy when a result depends on two checks instead of one.

Formula Meaning Best Use
=IF(B2>=60,"Pass","Fail") One numeric test Grades, targets, limits
=IF(C2="Paid","Closed","Open") One text test Status labels
=IF(A2="","Missing","Filled") Blank check Forms, trackers, imports
=IF(AND(B2>=50,C2>=80),"Bonus","No Bonus") Two rules must pass Commissions, eligibility
=IF(OR(D2="Yes",E2="Yes"),"Start","Wait") One of two rules can pass Approvals, checklists

When Nested IF Is Fine And When To Switch

A nested IF means putting one IF inside another. It works, and it can be useful for small grading bands or tiered pricing. A classic grade formula might test for A, then B, then C, and keep going until it finds the right match.

That said, nested formulas get hard to read once they grow. If you need many conditions, use a cleaner option when Excel offers one. Microsoft’s IFS function page shows a neater way to handle a longer list of true tests.

Use Nested IF For Short Decision Chains

A small grade check might look like this:

=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","D")))

This is still readable because the chain is short and the order is easy to follow.

Use IFS Or Lookup Methods For Longer Rules

If your formula starts stretching across the formula bar, step back. Long chains are harder to edit and easier to break. In those cases, IFS or a lookup table usually makes the sheet calmer and easier to hand off.

Practice Formulas You Can Adapt

These patterns are worth saving because they fit a lot of day-to-day work:

  • =IF(B2>0,"Profit","Loss")
  • =IF(C2>=18,"Adult","Minor")
  • =IF(D2="Yes","Approved","Pending")
  • =IF(E2
  • =IF(AND(F2>=50,G2="Yes"),"Qualified","Not Qualified")

Change the cell reference, change the rule, and the pattern still holds. That’s what makes IF so useful. You are not learning dozens of separate formulas. You are learning one sentence structure that can flex with the sheet.

A Simple Way To Check Your Formula

After writing an IF statement, test it with values that should land on both sides of the rule. If your cutoff is 70, try 69, 70, and 71. If your formula checks text, try a perfect match and a slightly different spelling. This catches small mistakes before they spread through a workbook.

Once you can write one clean IF statement, the rest of Excel starts to feel less stubborn. You stop guessing at syntax and start building rules on purpose. That’s the point where formulas stop being a headache and start doing real work for you.

References & Sources