October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Write an IF Formula in Excel: Examples and Tips

Excel’s IF function tests a condition and returns one result when true and another when false. See the syntax, examples, and ways to handle multiple conditions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Excel’s IF function to test a condition and return one result when it is true and another when it is false. Its basic syntax is =IF(logical_test, value_if_true, [value_if_false]). For example, =IF(A2>B2,"Over Budget","OK") displays “Over Budget” when A2 is greater than B2 and “OK” otherwise. The syntax is established Excel functionality, not a change introduced for 2026.

How the IF formula works

An IF formula has three parts: a test, a result for a true test, and an optional result for a false test. Microsoft’s IF function guide describes it as a logical comparison that returns a result depending on whether the condition is true or false.

As an Amazon Associate I earn from qualifying purchases.

In =IF(logical_test, value_if_true, [value_if_false]), the square brackets indicate that the third argument is optional; do not type the brackets into the formula. If you omit the false result, Excel returns FALSE when the test is false.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • logical_test is the condition to evaluate, such as A2>B2 or C2="Yes".
  • value_if_true is what Excel returns if that condition is met.
  • value_if_false is what Excel returns otherwise; choose it explicitly when you want a useful alternative to FALSE.

How to enter an IF formula

  1. Select the cell where you want the result.
  2. Type =IF(, then enter the condition, such as A2>B2 or C2="Yes".
  3. Type a comma and the result for a true condition. Put literal text in quotation marks, for example "Over Budget"; numbers do not need quotation marks.
  4. Type another comma and the result for a false condition, then close the parenthesis. Press Enter.
  5. Adapt the cell references and outputs to match your worksheet.

For example, =IF(C2="Yes",1,2) returns 1 when C2 contains “Yes” and 2 otherwise. Excel’s Formula AutoComplete can suggest function names and arguments as you type = and the start of a function name; see Microsoft’s guide to using functions and nested functions.

IF formula examples you can adapt

Purpose Formula What it returns
Compare two amounts =IF(A2>B2,"Over Budget","OK") “Over Budget” if A2 is greater than B2; otherwise “OK.” This follows Microsoft’s example in its IF function guide.
Check a score =IF(A2>=70,"Pass","Check") “Pass” at 70 or higher; “Check” below 70. The threshold is illustrative, not a Microsoft grading standard.
Return a status from text =IF(C2="Yes","Ready","Wait") “Ready” when C2 matches “Yes”; otherwise “Wait.”
Return a calculation or blank =IF(A2=B2,B4-A4,"") Calculates B4 minus A4 when A2 equals B2; otherwise returns an empty text string, so the cell appears blank. This is a Microsoft-documented example.

Use AND or OR when a test has multiple conditions

Combine a test with AND when every condition must be true, or with OR when any one condition is enough. Microsoft’s guide to IF with AND, OR, and NOT includes examples using numbers, text, and dates.

  • Every condition must hold: =IF(AND(A2>0,B2<100),"Pass","Check") returns “Pass” only if A2 is greater than 0 and B2 is less than 100.
  • Either condition may hold: =IF(OR(A2="Yes",B2="Yes"),"Eligible","No") returns “Eligible” if either cell contains “Yes.”
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose nested IF or IFS for ordered outcomes

When you need several outcomes in sequence, a nested IF puts another IF in the false-result argument. For example, Microsoft’s grade formula checks from the highest threshold down: =IF(D2>89,"A",IF(D2>79,"B",IF(D2>69,"C",IF(D2>59,"D","F")))). The order matters: test the highest cutoff first, or a broader condition could capture a value intended for a higher grade. Microsoft explains this pattern and its maintenance trade-offs in IF function: nested formulas and avoiding pitfalls.

Where available, IFS expresses ordered condition-and-result pairs without nesting each IF: =IFS(D2>89,"A",D2>79,"B",D2>69,"C",D2>59,"D",TRUE,"F"). The final TRUE,"F" pair supplies the default when none of the earlier conditions matches. Without a matching condition, IFS can return #N/A. Microsoft lists IFS for Microsoft 365, Excel 2024, Excel 2021, and Excel 2019 in its IFS function reference; check the version you use rather than assuming the function is available in every spreadsheet application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the approach that fits the logic and the people who will maintain the sheet:

Approach Best fit Main consideration
One IF One condition with two possible outcomes Choose both outcomes deliberately; the false result can be omitted, but then Excel returns FALSE.
IF with AND or OR One outcome depends on multiple requirements AND requires every test to pass; OR requires at least one.
Nested IF Several ordered conditions, including versions without IFS Long chains are harder to build, check, and update.
IFS Several ordered conditions in a supported Excel version Add a final default condition if unmatched values need a defined result.

Microsoft also documents conditional formulas in its Create conditional formulas guide.

Check common IF formula problems

  • Literal text needs quotation marks. Write "Yes" for text in a test or result, not Yes.
  • Close every function call. A nested formula needs one closing parenthesis for each open IF or other function.
  • Check threshold order and boundaries. Test representative values at, just below, and just above each cutoff to confirm that every value gets the intended result.
  • Define what happens when nothing matches. For IFS, a final TRUE,"Default" pair is one way to cover remaining cases.
  • Simplify formulas that are hard to audit. A helper column can make intermediate tests visible; IFS may make ordered logic easier to read in a supported version. Microsoft cautions that complex nested formulas are difficult to build, test, and update.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.