If IsEmpty(Range("A1").Value) Then runs the next line when A1 has nothing in it. IsEmpty returns True only for a cell that has never been filled or has been cleared, and False for anything else.
A formula that returns "" looks blank but isn’t empty, so IsEmpty returns False for it. To treat those cells as blank too, test the value instead: If Range("A1").Value = "" Then. Add Trim, as in If Trim(Range("A1").Value) = "" Then, to treat cells holding only spaces as blank as well.
To check a whole range at once, count instead of looping. WorksheetFunction.CountA(Range("A1:A10")) = 0 is True when every cell is empty, and WorksheetFunction.CountBlank(Range("A1:A10")) returns the number of blank cells, including formulas that return "".
To mark the empty cells, Range("A1:A10").SpecialCells(xlCellTypeBlanks).Interior.Color = RGB(255, 199, 206) colours them all in one step. It stops with error 1004 when there are no empty cells, so put it between On Error Resume Next and On Error GoTo 0.
To check if a cell is empty, you can use VBA’s ISEMPTY function. In this function, you need to use the range object to specify the cell you want to check, and it returns true if that cell is empty; otherwise, it returns false. You can use a message box or a cell to get the result.
Use VBA to Check IF a Cell is Empty
- Start with the function name “IsEmpty”.
- Specify the cell that you want to check.
- Use a message box or a cell to get the result value.
- In the end, run the code.
MsgBox IsEmpty(Range("A1"))
In most cases, you will use IsEmpty with an IF statement, so the code does one thing when the cell is empty and another when it has a value:
Sub check_cell_empty()
If IsEmpty(Range("A1")) Then
MsgBox "Cell A1 is empty."
Else
MsgBox "Cell A1 has a value."
End If
End Sub
And to check if a cell is not empty, add Not before IsEmpty, like If Not IsEmpty(Range(“A1”)) Then. You can also use ActiveCell instead of Range(“A1”) to check the cell that is selected.

Check IF Multiple Cells Are Empty
If you want to check and count the empty cells in a range, you need to loop through each cell in the range.
Sub vba_check_empty_cells() Dim i As Long Dim c As Long Dim myRange As Range Dim myCell As Range Set myRange = Range("A1:A10") For Each myCell In myRange c = c + 1 If IsEmpty(myCell) Then i = i + 1 End If Next myCell MsgBox _ "There are total " & i & " empty cell(s) out of " & c & "." End Sub
The above code loops through each cell in the range A1:A10 and checks each cell individually using the ISEMPTY function to determine whether it’s empty or not. It counts each empty cell and, in the end, shows a message box with the total number of cells and empty cells.
Use the following code if you want to highlight empty cells as well.
Sub vba_highlight_empty_cells() Dim i As Long Dim c As Long Dim myRange As Range Dim myCell As Range Set myRange = Range("A1:A10") For Each myCell In myRange ' c = c + 1 If IsEmpty(myCell) Then myCell.Interior.Color = RGB(255, 87, 87) i = i + 1 End If Next myCell MsgBox _ "There are total " & i & " empty cell(s) out of " & c & "." End Sub
Check IF an Entire Range Is Empty
If you only want to know whether the whole range is empty, you don’t need a loop. Use the worksheet function COUNTA, which counts the cells that are not empty. If it returns 0, all the cells in the range are empty.
Sub check_range_empty()
If WorksheetFunction.CountA(Range("A1:A10")) = 0 Then
MsgBox "All the cells are empty."
Else
MsgBox "The range has at least one value."
End If
End Sub
To select or work with all the empty cells of a range in one go, you can also use the Special Cells method with xlCellTypeBlanks. Just note that it gives the “No cells were found” error (1004) when the range has no empty cells.
Cells That Look Empty but Are Not
IsEmpty returns true only when there is nothing in the cell. So, it returns false for a cell that looks empty but has:
- A formula that returns a blank: like a formula that shows “” when there’s no value.
- Only spaces: a space typed into the cell or left over from imported data.
To treat these cells as empty as well, check the length of the value after removing the spaces with Trim:
Sub check_cell_looks_empty()
If Len(Trim(Range("A1").Value)) = 0 Then
MsgBox "Cell A1 is empty or has only spaces."
End If
End Sub
The same goes for COUNTA: it counts a cell with a formula that returns “” as not empty.
Frequently Asked Questions
What is the difference between IsEmpty and checking for “”?
IsEmpty(Range(“A1”)) is true only for a cell with nothing in it. Range(“A1”).Value = “” is true for an empty cell and also for a cell with a formula that returns “”.
Why does IsEmpty return false for a blank cell?
Because the cell isn’t really empty. It has a formula, a space, or some other character you can’t see. Check the cell in the formula bar, or use the Len and Trim check shown above.
Can I use IsEmpty on a range of cells?
No, IsEmpty checks one cell at a time. For a range, loop through the cells as shown above, or use COUNTA to check the whole range at once.
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.