Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel IF Statement for Not Null: How to Check Blank Cells

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To create an IF statement for "not null" (meaning the cell is not blank) in Excel, use the formula =IF(A1<>"", "Not Blank", "Blank"). The <> symbol is the logical operator for "is not equal to," and the double quotes with nothing between them "" represent an empty string or a null value. This allows Excel to trigger a specific action only when a cell contains data, which is essential for data validation, calculating totals only for completed entries, or flagging missing information in a large dataset.

What You'll Need

  • A computer with Microsoft Excel installed (works in all versions, including Office 365, Excel 2021, 2019, and Excel Online).
  • A dataset containing at least one column with some empty cells and some populated cells.
  • Basic familiarity with how to click into a cell and type a formula.

Step-by-Step

  1. Identify your target cell: Locate the cell you want to check for data. For this example, we will assume your data is in cell A2 and you want the result of the IF statement to appear in cell B2.
  2. Select the result cell: Click on cell B2 to make it the active cell.
  3. Begin the IF function: Type =IF( into the cell. The IF function requires three parts: the logical test, the value if true, and the value if false.
  4. Enter the "Not Null" logical test: Type the cell reference followed by the "not equal to" operator and empty quotes. In our example, type A2<>"". This tells Excel: "Check if A2 is NOT equal to nothing."
  5. Define the "Value if True": Add a comma, then type what you want Excel to display if the cell is NOT null. If you want text, wrap it in quotes. For example, type ,"Has Data".
  6. Define the "Value if False": Add another comma, then type what you want Excel to display if the cell IS null (blank). For example, type ,"Missing".
  7. Close the formula: Type the closing parenthesis ) and press Enter. Your final formula should look like this: =IF(A2<>"", "Has Data", "Missing").
  8. Apply to the rest of the column: Hover your mouse over the bottom-right corner of cell B2 until the cursor turns into a small black cross (the fill handle). Click and drag this handle down to apply the formula to all corresponding rows in your dataset.

Common Mistakes

One of the most frequent errors is forgetting the double quotes when representing a null value. If you type =IF(A2<> , ..., Excel will return a formula error because it does not recognize a space or a gap as a valid logical value. You must use "" to explicitly tell Excel you are looking for an empty string.

Another common mistake is confusing the <> operator with the = operator. If you use =IF(A2="", "Has Data", "Missing"), you have inverted the logic. In this case, Excel will mark blank cells as "Has Data" and populated cells as "Missing." Always double-check that the "not equal to" symbol is used when your goal is to identify non-null cells.

Users also frequently forget that Excel treats a cell containing a space character (hitting the spacebar once) as a populated cell. To the human eye, the cell looks empty, but to the <>"" logic, it is not null because a space is a character. This can lead to "False Positives" where the formula says a cell has data when it appears blank.

Lastly, avoid using the ISBLANK function if your cells contain formulas that return empty strings. The ISBLANK function only returns TRUE if the cell is truly empty (no formula, no space, nothing). If a cell has a formula like =IF(1=2, "Yes", ""), the cell looks empty, but ISBLANK will see the formula and return FALSE. Using <>"" is generally more reliable because it checks the resulting value of the cell, not just the physical state of the cell.

Tips

Using Formulas as the Result: You don't have to return text like "Has Data." You can return another calculation. For example, if you only want to calculate tax if a price is entered in A2, use =IF(A2<>"", A2*0.15, 0). This ensures your sheet doesn't show errors or zeros in rows where no data has been entered yet.

Combining with AND/OR: If you need to check if multiple cells are not null before performing an action, wrap the logical tests in an AND function. For example: =IF(AND(A2<>"", B2<>""), "Complete", "Incomplete"). This formula will only return "Complete" if both cell A2 and B2 contain data.

Handling Hidden Spaces: To prevent cells with accidental spaces from being counted as "not null," wrap your cell reference in the TRIM function. Use =IF(TRIM(A2)<>"", "Has Data", "Missing"). The TRIM function removes all leading and trailing spaces, ensuring that a cell containing only spaces is treated as truly null.

Visual Cues with Conditional Formatting: Instead of creating a new column with an IF statement, you can use the same logic in Conditional Formatting. Go to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format. Enter =A2<>"" and set a fill color. This will highlight every cell that is not null without needing extra columns.

Troubleshooting

If your formula is returning a #NAME? error, check your spelling of the IF function and ensure you haven't accidentally typed a character outside of the quotes. This error usually means Excel doesn't recognize the text you've typed as a valid function or defined name.

If the formula returns "Has Data" for a cell that looks completely empty, it is likely that the cell contains a hidden character, such as a non-breaking space from a web import or a carriage return. To fix this, select the cell and press the Delete key on your keyboard. If the formula result changes to "Missing," you know there was a hidden character present. To solve this for a whole column, use the Find and Replace tool (Ctrl+H) to find spaces and replace them with nothing.

If you see the literal formula =IF(A2<>"", "Has Data", "Missing") written in the cell instead of the result, your cell is likely formatted as "Text." Excel treats anything in a Text-formatted cell as a literal string rather than a calculation. To fix this, select the cell, go to the Home tab, change the Number Format dropdown from "Text" to "General," and then double-click the cell and press Enter to force it to recalculate.

If the formula returns #VALUE!, check that you haven't accidentally included a symbol or a character that Excel cannot process within the logical test. Ensure your quotes are straight quotes ("") and not "curly" or "smart" quotes, which often happen if you copy and paste a formula from a word processor like Microsoft Word.

Frequently Asked Questions

What is the difference between <>"" and ISBLANK?

The <>"" method checks if the value displayed in the cell is not an empty string. ISBLANK checks if the cell is absolutely empty. If a cell contains a formula that results in a blank value, <>"" will correctly identify it as blank, while ISBLANK will see the formula and call it "not blank."

Can I use this to count how many cells are not null?

While you can use an IF statement to mark them, the COUNTA function is faster for counting. =COUNTA(A2:A100) will count every cell in that range that is not null. However, if you need a specific condition (like "count if not null AND greater than 10"), you should use COUNTIFS.

How do I leave the cell blank if the target cell is null?

To make the result cell appear empty when the target cell is null, use empty quotes as the "Value if False." For example: =IF(A2<>"", "Valid", ""). This keeps your spreadsheet looking clean by hiding the "Missing" or "Blank" labels.

Does this work for numbers and dates?

Yes. In Excel, the <>"" logic works regardless of the data type. Whether the cell contains a number, a date, a percentage, or text, it will be considered "not null" as long as the cell is not empty.

Can I check if a cell is null instead of not null?

Yes. Simply change the operator from <> (not equal to) to = (equal to). The formula =IF(A2="", "Blank", "Not Blank") will trigger the first result only when the cell is null.