How to use the Excel IF function: basic writing method of conditional judgment

Explain the basic structure of single-condition judgment of the IF function in Excel, including how to write the condition, how to fill in the true value and false value, why the text result needs to be in quotation marks, and give the filling steps and the result verification method.

Key points of this article

  • The single condition structure of the IF function is "=IF (condition, result when true, result when not true)", and the three parts are separated by English commas.
  • Conditions are written using comparison symbols (>, <, >=, <=, =, <>). When the result is text, it should be enclosed in English double quotes.
  • Numeric results are written directly, and cell references are also written directly without quotation marks, otherwise they will be treated as ordinary text.
  • After writing the formula, use several rows of raw data to compare the results one by one, which is more reliable than just looking at the first row.

Many people are used to manually filling in line by line when making judgments in Excel for the first time, such as marking "pass" or "fail" based on grades. It can still be handled when there are only a few dozen rows in the form, but when there are too many data, it is easy to miss corrections or fill in errors. The IF function is designed for scenarios such as "display A if the condition is met, otherwise display B". You can write the formula once and the result will be automatically obtained for the entire column.

This article is written for readers who can use Excel but have not yet written an IF formula. After reading, you can write single-condition IF formulas, know how to fill in true and false values, and check whether the results are correct. The writing method of nesting multiple conditions is beyond the scope of this article and will be discussed in a later article.

How to use Excel function IF? One sentence conclusion

Use the structure of "=IF(condition, result when the condition is true, result when the condition is not true)". Write the judgment in the first position, and write the two results in the last two positions respectively. Excel will return the corresponding result based on whether the condition is true.

your situationRecommended practicesThe reason
As long as you judge one condition, there are two possible outcomesDirectly use single-layer IF, such as =IF(B2>=60, "Pass", "Fail")Simple structure and easy to inspect
The result is text, such as "pass" or "yes"English double quotation marks on both sides of the textExcel treats unquoted content as a name or function, which easily causes errors
The result is a number or another cellDirectly write numbers or cell addresses, such as =IF(B2>=60,B2,0)Numbers and references do not require quotation marks, and the calculation results can continue to be used in the calculation
Check if a cell is emptyCompare with blank text, such as =IF(B2="","Unfilled","Filled")Can exclude blank lines in advance to avoid misjudgment
Condition has more than two resultsTemporarily split into multiple single-layer IFs, or leave for multi-conditional writingA single-layer IF only handles two scenarios: "True" and "Not True."

Before you start: Confirm these points first

Before taking action, take a minute to confirm the following items, which can save you the trouble of most error reports and incorrect results.

  • Determine whether the data to be judged is numbers or text. Numbers can be directly compared in size. Numbers copied from elsewhere are sometimes saved as text, look the same, but cause errors when compared. Text is usually left aligned, so check that first.
  • Are you using the correct comparison symbols? Greater than, less than, greater than or equal to, less than or equal to, equal to, and not equal to are represented by ">""<"">=""<=""="="<>" respectively. Writing "greater than or equal to" as "=>" will result in an error.
  • Is the result a text or a number. Text results must be enclosed in English double quotes, but numbers and cell references are not. This determines whether the formula can be displayed normally.
  • Whether the input method is in English state. The equal signs, brackets, commas and quotation marks in the formula must use English half-width symbols. Chinese punctuation is a common source of error for newbies and is often not recognized by Excel.

Steps to write an IF formula in Excel

Here is an example: Column B is the score. To display "pass" or "fail" in column C, the dividing line is 60 points.

  1. Select the cell where you want to display the results, for example C2.
  2. Enter the equal sign and function name, written as "=IF(".
  3. Write a condition, such as "B2>=60", which means that the condition is true when B2 is greater than or equal to 60.
  4. Enter an English comma, and then write the result when the condition is true, that is, ""passed"". Pay attention to the English double quotes.
  5. Then enter an English comma and write the result when the condition is not met, that is, ""failed"".
  6. Enter the right bracket ")", the complete formula is =IF(B2>=60, "pass", "fail"), and press Enter to confirm.
  7. Drag the fill handle in the lower right corner of the cell to copy the formula downward. B2 in the formula will automatically change to B3 and B4 along the lines, so the corresponding score will be judged in each line.

After completion, check each item one by one

After filling in the formula downward, don't trust the result directly; check the items below.

Inspection itemsHow to see itWhat should you do if there's a problem?
Whether the results meet expectationsFind lines 3 to 5 and compare them one by one with the original score, including the line that is exactly 60If the critical value result is incorrect, check whether the comparison symbol is ">=" or ">".
Check if an error message appearsThe result shows an error value like #NAME?Check the spelling of function names and whether Chinese punctuation is mixed in
Check whether the text result is in quotation marksIn the formula box, English quotation marks are placed on both sides of the textFill in the missing quotation marks and press Enter again
Is the data digital?Calculate an addition once for the suspicious cells to see if normal summing is possibleConvert text to numbers before applying formulas
Check if the reference is correct after fillingOpen the formula in the cell below and see if the row number in column B changes accordinglyIf the line number hasn't changed, it means the address is locked and changed to relative reference
Handling of blank linesLook at what the blank line at the end or middle of the table showsAdding null value judgments to formulas to avoid leaving blank lines to indicate "fail"

❓ Frequently Asked Questions (FAQ)

1. After entering a formula, the cell displays the formula text, not the result. What should I do?

First, check whether the cell format is set to "Text". The input content in text format is preserved as is and is not calculated. After changing the format to normal, re-enter or double-click the cell and press Enter.

2. Can the results of the IF be directly involved in the calculation?

Yes, you can. For example, =IF(B2>=60, B2*0.1,0) means returning one-tenth of the score when passing, and 0 when failing. In this case, the result is a number and does not require quotation marks.

3. Can the conditions compare text, for example, determining whether a certain grid is "yes"?

Yes, you can. Just write =IF(C2="Yes", "Pass", "Fail"). When comparing text, the text in the condition should also be enclosed in English quotation marks, and the writing style must be exactly the same as the original data.

4. The numbers are clearly large, so why are the judgments always wrong?

A common reason is that the numbers are actually text. You can test it with addition. If the result is 0 or there is an error, it means the data is still text and needs to be converted to a number first. Additionally, when comparing, make sure the numbers in the condition match the units in the table, for example, one is a decimal and the other a percentage.

📝 Summary

The single-condition notation of the IF function can be summarized into three parts: "condition, result when true, result when not true." First, confirm the data type and punctuation format, then fill in the form step by step, and finally cross-check the results with several rows of original data. This way, you can basically use it well. Once you master this structure, learning multi-condition judgment will be smoother.

Open OmniDoc and process your table file

Updated 2026-11-12