Microsoft Excel If Function Example
The IF function in Microsoft Excel tests a condition and returns one result when it is true and another when it is false. For example, =IF(A2>=70,"Pass","Fail") returns “Pass” for a score of 70 or above and “Fail” for a lower score. Use it to label.
Which licences fit your PC setup?
Prices are an AUD snapshot, not a live quote. Confirm variant and total on the listing.
-

Office 2021 Pro Plus key
$57.00 AUD
-

Office 2019 Pro Plus key
$45.00 AUD
-

Microsoft 365 Pro Plus, 5 devices
$15.00 AUD
$29.00
Understand the three parts of an IF formula
The syntax is =IF(logical_test, value_if_true, value_if_false). The logical test asks a question about your data. The next two arguments specify the results for each outcome, as described in Microsoft’s IF function reference.
- logical_test: the condition, such as A2>=70.
- value_if_true: the result when that condition is met, such as "Pass".
- value_if_false: the result when it is not met, such as "Fail".
Put text values inside straight double quotation marks. Numbers, cell references and calculations do not need quotation marks. Start the formula with an equals sign, and include both outcomes so the intended behaviour is clear.
Create a pass-or-fail example step by step
Suppose column A contains test scores and a score of 70 is the pass mark. Column B will display the result for each score.
- Enter Score in A1 and Result in B1.
- Enter 69 in A2, 70 in A3 and 85 in A4.
- Select B2 and enter =IF(A2>=70,"Pass","Fail").
- Press Enter. B2 should display Fail.
- Copy the formula from B2 down to B4. The results should be Fail, Pass and Pass.
The >= operator includes the boundary value of 70. Using > instead would require a score above 70. Testing values below, at and above a threshold helps catch this common mistake.
When you copy the formula down, A2 changes to A3 and A4 because it is a relative reference. To keep the pass mark in a separate cell, enter 70 in D1 and use =IF(A2>=$D$1,"Pass","Fail"). The dollar signs keep the threshold reference fixed when you copy the formula.
Choose the right comparison operator
Match the operator to the rule you actually want to apply. These examples assume A2 contains a number.
| Rule | Logical test | What it includes |
|---|---|---|
| Equal to 70 | A2=70 | Exactly 70 |
| Not equal to 70 | A2<>70 | Any number except 70 |
| Above 70 | A2>70 | Values greater than 70 |
| At least 70 | A2>=70 | 70 and higher values |
| Below 70 | A2<70 | Values less than 70 |
| At most 70 | A2<=70 | 70 and lower values |
Return a calculation instead of a label
IF can choose between numeric results as well as text. For a worked commission example, suppose sales above 1000 qualify for a 5% commission on the full sales amount. Sales of 1000 or less receive no commission.
=IF(A2>1000,A2*5%,0)
With sales of 1200 in A2, the result is 60. With sales of exactly 1000, it is 0. These are illustrative business rules: change the threshold and rate to match your actual commission agreement.
The formula calculates a value in its own cell. It does not update stock quantities elsewhere, send an alert or change another cell’s formatting.
Test multiple conditions with AND or OR
Use AND when every condition must be true, or OR when any condition can qualify. Microsoft’s guide to IF with AND and OR explains how these functions combine.
For example, if A2 contains sales and B2 contains an approval status, this formula requires both sales above 1000 and an Approved status:
=IF(AND(A2>1000,B2="Approved"),"Eligible","Not eligible")
For a separate rule that flags either low stock in A2 or an urgent status in B2, use:
=IF(OR(A2<10,B2="Urgent"),"Review","No action")
Check each condition separately before combining them. This makes it easier to identify whether a wrong result comes from the threshold, the text value or the choice between AND and OR.
Use nested IF formulas for several outcomes
A nested IF places another IF inside one of the result arguments. For sales categories, you could use:
=IF(A2<1000,"Low",IF(A2<5000,"Medium","High"))
Sales below 1000 return Low. Values from 1000 up to, but excluding, 5000 return Medium. Values of 5000 or above return High. This also handles decimal amounts between the thresholds.
Order matters: the second test is reached only when the first test is false. Keep the number of branches manageable. If categories change regularly, a separate lookup table can make the rules easier to inspect and maintain.
Handle text, dates and missing entries carefully
Match text without overgeneralising
=IF(A2="Apple","Fruit","Other")
This identifies Apple and labels everything else Other. Returning “Not fruit” for every other value would misclassify entries such as Pear. Make sure the false result describes all remaining possibilities accurately.
Flag overdue dates and leave empty rows clear
If A2 contains a due date, use:
=IF(A2="","",IF(A2<TODAY(),"Past due","Not past due"))
The outer IF returns empty text when A2 is blank or contains a formula returning empty text. Otherwise, the inner IF compares the date with today. A date equal to today returns Not past due. Enter dates as recognised Excel dates rather than text that only looks like a date.
Handle calculation errors deliberately
For a division such as A2/B2, =IF(B2=0,"Check divisor",A2/B2) checks specifically for a zero divisor. To supply a replacement result for any error in that calculation, use =IFERROR(A2/B2,"Check inputs"). Microsoft’s IFERROR reference describes this behaviour. Investigate unexpected errors before replacing them with a message.
Check the formula before filling a whole column
- Test every possible result, including exact threshold values and empty cells.
- Check that copied formulas refer to the intended row and retain any fixed threshold references.
- Use straight quotation marks and check that every opening parenthesis has a closing one.
- If Excel expects semicolons as argument separators, replace the commas in these examples with semicolons.
- For a colour change, use conditional formatting. A rule such as =A2>1000 already returns TRUE or FALSE; wrapping it in IF is unnecessary.
For related spreadsheet guidance, browse the Microsoft Office articles. If Office setup is preventing you from practising, the separate guides to activating Microsoft Office using CMD and finding a Microsoft Office product key using Command Prompt cover those setup topics.
Start with the pass-or-fail example in a blank worksheet, verify all three test scores, then replace the threshold and labels with one rule from your own work.
Other editions for separate workloads
Other editions for separate workloads; prices in AUD, confirm the total on the listing.
-

Windows 11 Pro key
$14.99 AUD
$29.00 -

Office 2024 Pro Plus key
$20.00 AUD
$39.00 -

Windows 11 Home key
$18.88 AUD
$37.00
How to check this worked
- Open Settings, System, Activation and confirm the edition shown.
- Enter the key and run activation; expect a green tick within a minute.
- Reboot and re-check activation survives the restart.
FAQ
What else should you know before buying?
- What do I need before starting?
- Read the requirements and confirm the edition first; the steps assume the machine is compatible.
- How do I know the licence is genuine?
- Activate on Microsoft's servers and check Settings, System, Activation. A working activation is the test.
- Is this a subscription?
- Keys sold here are one-time lifetime licences. Microsoft 365 plans are billed by Microsoft instead.
- What if the key fails?
- Email hi@ms.codes with the order number and a screenshot. Replacement or refund applies within 30 days.
Check who prepared and reviewed this guide
- Written by
- MS.Codes editorial
- Reviewed by
- Support team
Last verified: (source review; see test status above).