In this example, the goal is to create a formula that will return "Done" in column E when a cell in column D contains a value. In other words, if the cell in column D is "not blank", then the formula should return "Done". In the worksheet shown, column D is is used to record the date a task was completed. Therefore, if the column contains a date (i.e. is not blank), we can assume the task is complete. This problem can be solved with the IF function alone or with the IF function and the ISBLANK function. It can also be solved with the LEN function. All three approaches are explained below.
The IF function runs a logical test and returns one value for a TRUE result, and another value for a FALSE result. You can use IF to test for a blank cell like this:
=IF(A1="",TRUE) // IF A1 is blank =IF(A1<>"",TRUE) // IF A1 is not blank
In the first example, we test if A1 is empty with ="". In the second example, the <> symbol is a logical operator that means "not equal to", so the expression A1<>"" means A1 is "not empty". In the worksheet shown, we use the second idea in cell E5 like this:
If D5 is "not empty", the result is "Done". If D5 is empty, IF returns an empty string ("") which displays as nothing. As the formula is copied down, it returns "Done" only when a cell in column D contains a value. To display both "Done" and "Not done", you can adjust the formula like this:
Another way to solve this problem is with the ISBLANK function. The ISBLANK function returns TRUE when a cell is empty and FALSE if not. To use ISBLANK directly, you can rewrite the formula like this:
The NOT function simply reverses the result returned by ISBLANK.
One problem with testing for blank cells in Excel is that ISBLANK(A1) or A1="" will both return FALSE if A1 contains a formula that returns an empty string. In other words, if a formula returns an empty string in a cell, Excel interprets the cell as "not empty". To work around this problem, you can use the LEN function to test for characters in a cell like this:
This is a much more literal formula. We are not asking Excel if A1 is blank, we are literally counting the characters in A1. The LEN function will return a positive number only when a cell contains actual characters.