Excel Formula Master Tricks for Empty Cells, Zeros, Zero Length Text String and 'Blanks'
Excel confusion: blank, empty cell, zero length text string, and it's all Microsoft's fault. Now, if you want to be a formula master, you have to watch this video, because it exposes a lot of hidden trouble with Excel formulas.
Introduction
Now, this cool question comes from Saeed Hassan in the comments. Here we have an empty cell. There's the number zero. Here's a zero length text string, which means in the formula there's double quote, double quote, with nothing between the quotes. This is common in formulas, like an invoice formula, when you want the formula to show nothing. Or over here, we're checking if double quote, double quote is in the cell. Now, this is different. That's text with a space, and we're going to see that even this sometimes will cause problems. And then there's the number 10.
Now what we're going to do is analyze these in all the possible ways in Excel.
Look at empty cells and zero length text strings and a space.
The first way: in a formula, an empty cell always evaluates to zero. So equals that's truly an empty cell. It doesn't have zero in it, but if you use that cell in a formula and hit F9, you can see it evaluates to zero. Control Z, and when you enter it, it returns a zero. That means if we ask the question, "Hey, empty cell, are you equal to..." and that's a comparative operator, so it will return a Boolean TRUE or FALSE. I'm going to say, are those two things equal? And bam, yes, they are, because that cell inside the formula evaluates to zero.
In a formula, an empty cell always evaluates to zero.
Empty cell and zero compared with equal sign is TRUE.
A 'zero length text string', "", is text with zero length.
Now, a zero length text string is text with zero length. If we want to check whether that's a zero length text string, it's actually two steps. To check if a zero length text string is text, we use the ISTEXT function. ISTEXT, and if we point there and hit Tab, sure enough, that's TRUE. Actually, we can also check whether that space is text, and sure enough it is.
To check if zero length text string is text, use ISTEXT function.
To check if zero length text string has zero length, use LEN (length) function.
To check if a zero length text string has zero length, we use the LEN function. That's for length. The LEN of this had better be zero, and sure enough it is. And LEN of this, if there truly is one space, it'll be one.
Now, if we want to check if a zero length text string is both text and zero length with a single formula, then we have two tests, so we have to use the AND function. In the first argument of AND, we'll use ISTEXT, comma, and then length in the second argument. We have to ask the question with a comparative operator: is length equal to zero? And we get a TRUE.
To check if zero length text string is both text and zero length, use: AND function
Text can never equate to a number.
Next, text can never equate to a number. So if we make a formula and say, "Hey, zero length text string, are you equal to zero?" that's going to come out FALSE. But check out this next inconsistency. We know that text is not equal to an empty cell, but with a comparative operator, they are. If I say, "Zero length text string, are you equal to empty cell?" it comes out TRUE. I didn't even check up here. If we check the empty cell, is it text? We're going to get a FALSE value. So I'm not sure what's going on with this comparative operator, but that's something we need to know for building formulas.
'Null text string' or 'blank' are not accurate descriptions of a 'zero length text string'.
Now, "null text string" or "blank": these are not accurate descriptions of a zero length text string. The word null, in databasing and Power Query, means the absence of anything. And blank, I don't really know what that word means. Microsoft causes this confusion with their Help menu.
Microsoft helps to cause this confusion with Help
ISBLANK function: Blank = "empty cell". Function checks for empty cell.
Is blank actually checks if there's an empty cell? All right, so we'll just see if this is true. Is blank, I'm going to get a TRUE. But if I check zero length text string, ISBLANK is only checking for empty cells, so I get a FALSE. And what makes this confusing is that Microsoft then goes on with COUNTBLANK. It will count the empty cell and the zero length text string. So if I count blank across all of these, I'd better only get one and two, and sure enough, when I hit Enter, the word blank here means zero length text string and empty cell, and up here it means only empty cell.
COUNTBLANK function: Blank = "empty cell or zero length text string".
Paste Special 'Skip Blanks': Blank = "empty cell".
There are other places in Microsoft Excel where they use the word blank. When we use Paste Special, Skip Blanks, that word blank there means empty cell. The way this works is when we highlight this and Control C to copy 6, 12, and a zero length text string, they will be pasted over the data. But because there's an empty cell right there, it'll keep the seven. So in the top cell, right-click, Paste Special. In the Paste Special dialog box, I check Skip Blanks and click OK. The 6, the 12, and the zero length text string are pasted. The only cell where something wasn't pasted was this cell, because that is an empty cell. So when it says Skip Blanks, it really means skip empty cells.
Filter: Blank = "empty cell or zero length text string or space".
Here's where it gets really crazy. Filter: what does blank mean? Empty cell, or zero length text string, or a space. I couldn't find help on this in the latest version, but all the way back in 2010, Help said the Blanks check box is available only if the range of cells or table column contains at least one blank cell. And check this out: when I select Blanks, it's got an empty cell, a zero length text string, and a text formula for a space.
Criteria in SUMIFS, COUNTIFS and the like: 1) "NOT" will return a TRUE for any cell that is NOT "empty". "=" will return a TRUE for any cell that is "empty".
Now, if we get to SUMIFS and COUNTIFS, the criteria in double quotes, "not," that's a less than and greater than symbol, will return a TRUE for any cell that is not empty. Whereas on the other hand, criteria that has an equal sign in double quotes will return a TRUE for any cell that is empty. So if you really want to count everything that's not empty for SUMIFS or COUNTIFS or MAXIFS or any of those, we use MAXIFS. We look through here, comma, and then in double quotes, not. That means not empty. In our case, we'd better get a count of 4, since that's the only cell that's empty. If we use equals with COUNTIFS, SUMIFS, or MAXIFS on this range, comma, and in double quotes we use an equal sign, that counts only empty cells, and we get a count of one.
Logical formulas.
Now the last topic is logical formulas. Logical formulas with comparative operators that use a zero length text string see both an empty cell and a zero length text string.
The Logical Test: C37="", asks: "Is cell empty or Zero Length Text String"
The Logical Test: C37=NOT"", asks: "Is cell NOT empty or NOT Zero Length Text String"
So if we have equals, double quote, double quote, that asks the question: is the cell empty or a zero length text string? If we create the logical formula with not, double quote, double quote, that asks: is the cell not empty or not zero length text string? So we'll try this. We'll say, "Hey, that cell right there, are you equal to double quote, double quote?" Control Enter, double-click, and send it down, and it sees both the empty cell and the zero length text string.
Formula to check for empty cell.
Now we can use ISBLANK if we really want to see if it's empty. This time I'm going to do a spilled array formula. So I highlight all the potential relative cell references that I had to copy over here, and when I close parentheses and hit Enter, it spills. Of course, ISBLANK is only checking empty.
Formula to check if cell is not empty
Now we could say not, is that cell not double quote, double quote? Because it checks both, when I Control Enter, I get a FALSE there. Double-click and send it down. And over here, if we wanted to actually check not empty, not ISBLANK, the whole column, close, close, and Enter. So all of these are not empty, and of course this one is FALSE because it is empty.
Summary of video.
All right, that was a lot of fun with double quote, double quote, zero length text string, blank, zero, and empty cell. We saw it with logical formulas. We saw it with COUNTIFS and SUMIFS as a criteria in the criteria argument. We saw it with FILTER, Paste Special Skip Blanks, COUNTBLANK, and ISBLANK. And we even saw some logical formulas up here using ISTEXT, LEN, and the AND function.
Closing and video links
All right, if you like that video, be sure to click that thumbs up, leave a comment, and subscribe, because there's always lots more videos to come from XLSFun. All right, we'll see you next video.
