For Excel if not blank, use =IF(A2<>"","Not blank","Blank"). It returns "Not blank" when A2 contains anything and "Blank" when A2 is empty.
The <> operator means "not equal to", and two quotation marks with nothing between them mean empty text. Together, A2<>"" asks whether A2 holds something. This article covers that formula, the ISBLANK alternative, how to test several cells at once, and the cases where a cell looks empty but a formula says it is not. In every example, A2 is the cell being checked and the formula sits in B2, ready to fill down.
Which formula should you use?
| Goal | Formula |
|---|---|
| Not blank, simple | =IF(A2<>"","Not blank","Blank") |
| Not blank, using ISBLANK | =IF(NOT(ISBLANK(A2)),"Not blank","Blank") |
| Not blank, ignoring spaces | =IF(LEN(TRIM(A2))>0,"Not blank","Blank") |
| All of several cells filled | =IF(AND(A2<>"",B2<>"",C2<>""),"Complete","Missing") |
| Any of several cells filled | =IF(OR(A2<>"",B2<>""),"Some data","Empty") |
| Count the non-blank cells | =COUNTA(A2:A100) |
Excel IF not blank with the not-equal operator
=IF(A2<>"","Not blank","Blank")
This is the formula most people want. IF takes three arguments: IF(logical_test, value_if_true, [value_if_false]). Microsoft's documentation describes logical_test as the condition you want to test, and only value_if_false is optional. Here the test is A2<>"". It is TRUE when A2 holds a value and FALSE when A2 is empty, so IF returns the first label or the second.
Example output, with the formula filled down from B2:
| A (cell) | B (formula result) |
|---|---|
| Invoice 1041 | Not blank |
| 0 | Not blank |
| (empty) | Blank |
| Paid | Not blank |
Notice that the number 0 counts as not blank. A zero is a value, and the test only asks whether the cell holds something. If you want to treat zero as empty too, add a second condition: =IF(OR(A2="",A2=0),"Blank","Not blank").
Return the cell value, or nothing
The most common real use is to show a result only when an input exists. Without the guard, a formula that depends on an empty cell shows a misleading 0 or an error. Wrap it:
=IF(A2<>"",A2*1.2,"")
When A2 is filled, the cell shows A2 multiplied by 1.2. When A2 is empty, the cell shows nothing. Microsoft's IF page includes the same idea in its own example, =IF(A2=B2,B4-A4,""), where empty text keeps the cell visually clear. Remember that this result is empty text, not a truly empty cell. That matters in the section on empty text below.
Use ISBLANK for a stricter test
=IF(ISBLANK(A2),"Blank","Not blank")
Microsoft documents ISBLANK as returning TRUE if its argument is a reference to an empty cell, and FALSE for anything else. Excel has no ISNOTBLANK function, so to flip the test you either swap the two labels, as above, or wrap ISBLANK in NOT:
=IF(NOT(ISBLANK(A2)),"Not blank","Blank")
Swapping the labels is shorter and easier to read. Use NOT only when the condition is part of a longer formula where you cannot reorder the results.
ISBLANK and A2<>"" are not identical. ISBLANK is TRUE only for a truly empty cell. A cell holding a formula that returns empty text is not empty, so ISBLANK reports FALSE for it. The comparison A2<>"" tests the cell's value, and a cell showing empty text compares as equal to "". You can see the difference yourself: put ="" in A2, then enter =ISBLANK(A2) and =A2<>"" in two other cells. The first returns FALSE and the second returns FALSE as well, so the two tests disagree about what "blank" means. ISBLANK says "this cell is not empty", while the comparison says "this value is not empty text".
Check that several cells are not blank
To flag a row as complete only when every required field is filled, combine the tests with AND:
=IF(AND(A2<>"",B2<>"",C2<>""),"Complete","Missing")
Microsoft documents AND as returning TRUE when every condition passes and FALSE when at least one fails, with up to 255 conditions. To flag a row when at least one field is filled, swap AND for OR:
=IF(OR(A2<>"",B2<>""),"Some data","Empty")
For a whole range, counting is shorter than listing cells. Compare the number of filled cells with the number of cells in the range:
=IF(COUNTA(A2:C2)=3,"Complete","Missing")
COUNTA counts cells that hold any type of information. Microsoft's page states that it does not count empty cells. The number 3 is the width of A2:C2, so change it if you change the range. The same function gives the total for a column, =COUNTA(A2:A100), which is useful for a quick "how many rows are filled in" cell.
Why a cell that looks empty is "not blank"
Most wrong answers from these formulas come from cells that look empty but are not. Three causes are common.
- A space. A cell holding a single space looks empty, but it is text. Both ISBLANK and
A2<>""report it as not blank. Use=IF(LEN(TRIM(A2))>0,"Not blank","Blank"): TRIM removes spaces from the ends and collapses repeated spaces inside, and LEN returns the length of what is left. A cell of only spaces then has length 0. TRIM removes the ordinary space character, so a non-breaking space pasted from a web page can survive it. Check the cell's length with=LEN(A2)if the formula still misbehaves. - A formula that returns empty text. A cell containing
=IF(X2="","",X2)displays nothing when X2 is empty, but the cell holds a formula. ISBLANK treats it as not blank. COUNTA counts it too: Microsoft's COUNTA page says the function counts cells with any type of information, including error values and empty text. If a column is filled by formulas, COUNTA can return more than the number of visibly filled cells. - An apostrophe. Typing a leading apostrophe forces Excel to treat the entry as text. A cell with only an apostrophe displays nothing, but it is not empty. Click the cell and look at the formula bar.
When in doubt, use the LEN and TRIM version. It ignores spaces and treats empty text as empty, which is what most people mean by blank.
Do something else when a cell is blank
The same pattern works for other labels and actions:
- Fill a default:
=IF(A2<>"",A2,"N/A")shows the cell's value, or "N/A" if it is empty. - Check a lookup source first:
=IF(E2<>"",VLOOKUP(E2,$H$2:$I$50,2,FALSE),"")runs the lookup only when a key was entered, so empty rows stay clean. - Return a number for later maths:
=IF(A2<>"",1,0), then total the column withSUM. - Several outcomes: nest one IF inside another, for example
=IF(A2="","Missing",IF(B2="","Half done","Done")). Microsoft's IF page says you can nest multiple IF functions but does not state a limit, so keep nesting shallow.
Be careful with the optional third argument. If you leave out both result arguments, Microsoft notes that the cell shows 0. Always supply both, even if one is "".
Highlight cells that are not blank
To colour filled cells instead of writing a helper column, use conditional formatting. On the Home tab choose Conditional Formatting, then New Rule, then "Use a formula to determine which cells to format". Enter =$A2<>"" with the rule applied to your range. The formula is written for the first row of the range, and the dollar sign before the column letter keeps it pointing at column A as the rule applies across the range. To highlight blank cells instead, use =$A2="".
If the formula gives the wrong answer
- Every row says "Not blank". The cells probably hold spaces, apostrophes, or formulas returning empty text. Switch to the LEN and TRIM test.
- ISBLANK says FALSE, but the cell shows nothing. The cell contains a formula or text. ISBLANK is TRUE only for a truly empty cell.
- A zero is treated as filled. That is correct behaviour for the not-equal test. Add
A2=0to an OR condition if you want zero treated as empty. - The result shows 0 instead of a label. One of the IF result arguments is missing. Give both explicitly.
- Results shift when you fill down. A fixed reference such as
$E$1stays put, while A2 moves one row per row. Lock only the references that should not move.
If you need to test whether a cell contains a certain word rather than whether it contains anything, see Excel IF cell contains text, which covers SEARCH, COUNTIF and wildcards.
Frequently asked questions
- How do I write IF not blank in Excel?
- Use =IF(A2<>"","Not blank","Blank"). The <> operator means not equal, and "" is empty text, so the formula returns "Not blank" when A2 holds anything and "Blank" when it is empty. You can replace the two labels with any values or formulas.
- Is there an Excel function for not blank?
- There is no ISNOTBLANK function. Use NOT(ISBLANK(A2)) or the A2<>"" comparison. Microsoft documents ISBLANK as returning TRUE only when its argument is a reference to an empty cell, so a cell holding a formula that returns empty text is not blank to ISBLANK.
- Why does my not blank formula say a cell is filled when it looks empty?
- The cell probably contains a space, an apostrophe, or a formula that returns empty text. ISBLANK treats all of these as non-empty. Test with =LEN(TRIM(A2))>0 to ignore spaces, and check the cell in the formula bar to see what it holds.
- How do I count cells that are not blank in Excel?
- Use COUNTA, for example =COUNTA(A2:A100). Microsoft documents that COUNTA does not count empty cells, but it does count cells holding empty text such as the result of a formula that returns "", so the count can be higher than the number of visibly filled cells.