In Excel: Use If IsEmpty(ws.Range("A1").Value) Then for a truly untouched cell, or If ws.Range("A1").Value = "" Then when a formula returning "" should also count as blank.
VBA macro: Check Whether a Cell Is Empty
Sub CountEmptyCells()
Dim ws As Worksheet
Dim cell As Range
Dim emptyCount As Long
Set ws = ActiveSheet
For Each cell In ws.Range("A1:A20")
If IsEmpty(cell.Value) Then
emptyCount = emptyCount + 1
cell.Interior.Color = RGB(255, 235, 156)
End If
Next cell
If emptyCount = 0 Then
MsgBox "No empty cells in A1:A20.", vbInformation
Else
MsgBox emptyCount & " empty cell(s) highlighted.", vbExclamation
End If
End SubIsEmpty is True only for a genuinely untouched cell. A cell holding =IF(A1="","",A1) looks blank on screen but contains a formula, so IsEmpty returns False while .Value = "" returns True — the two tests answer different questions.
How to run this macro
- Press Alt + F11 to open the VBA editor.
- Insert > Module.
- Paste the code above.
- Press
F5, or close the editor and run it from Developer > Macros. - Save the file as .xlsm so the macro is kept.
Decide which blank you mean: never-typed-into, or displaying nothing.
For never-typed-into, test If IsEmpty(cell.Value) Then.
For displaying nothing, test If cell.Value = "" Then, or equivalently If Len(cell.Value) = 0 Then.
For a whole range or row, use If Application.WorksheetFunction.CountA(rng) = 0 Then instead of looping.
Test against real data containing at least one formula-blank, because that is the case where the two tests disagree.
What this does
Excel has more than one kind of blank, which is why this question has more than one answer. A cell that has never been typed into is Empty — IsEmpty returns True and it holds no value at all. A cell containing a formula that evaluates to "" looks identical on screen but is not empty: it holds a formula, so IsEmpty returns False while comparing .Value to "" returns True. A cell holding a single space is empty to neither test. Which test to use follows from which of those you mean. For a whole range there is a fourth option: Application.WorksheetFunction.CountA(rng) = 0 answers "is every cell in this range blank" in one call, without a loop, and is what row-deletion macros should use rather than testing one column and hoping. Len(cell.Value) = 0 is a common shorthand that behaves like the "" comparison and reads a little more clearly for text. Keep the inputs visible and clearly labelled and the whole thing stays auditable — anyone who opens the file later, including you, can see at a glance exactly what feeds the result and change one assumption without hunting through the formula. For “excel vba check if cell in range is empty”, the reliable version is a short checking loop, not just the first command that appears to work. Run it on a deliberately small range first, watch how the affected cells change, and only then apply the same setup to the full sheet. When this is a ribbon command, the selection matters more than the button: confirm the range, apply the command, then spot-check the output before saving. That is what makes a workflow that saves repeating the same clicks every week useful in real work: repeatable, auditable, and not dependent on memory or luck.
A worked example
You need to flag gaps in an ID column before importing the sheet. Sub CountEmptyCells() walks A1:A20, tests each cell with IsEmpty, shades the blanks pale amber and reports the total. Run it against a column where one cell holds =IF(B1="","",B1) and that cell will not be highlighted — correctly, because it is not empty, it merely displays nothing. If your import treats both as missing, swap the test to If cell.Value = "" Then and it will catch both. For the different question of whether an entire row is blank, drop the loop: If Application.WorksheetFunction.CountA(ws.Rows(i)) = 0 Then covers all 16,384 columns at once, which is why it is the right guard before deleting a row. Nearly every data-cleaning macro turns on this test, and getting it wrong is quiet rather than loud: rows are skipped or deleted based on a definition of "blank" that does not match the one in your head. Choosing deliberately between IsEmpty, the "" comparison and CountA is what makes the result predictable. If there is any chance you will reuse this, drop it into a small template tab right now: a labelled input area on the left and the formula beside it, checked once against the tool above. Next time the same question comes up, the answer is a single paste away instead of a rebuild from memory.
In Google Sheets
Everything above works in Google Sheets too. Excel and Sheets share the formula syntax used here; only the surrounding menus are arranged differently. That portability is deliberate — learn it once and it follows you between the two tools and across Windows and Mac. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top, the tool proves it, and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. If you take one thing from this page on “excel vba check if cell in range is empty”, make it the habit rather than the keystrokes: set the problem up with labelled inputs, reference those cells, and let Excel do the recomputing. Bookmark the page for the syntax, but do the example once in a blank sheet and check it against the tool above — five minutes of hands-on practice fixes the method in memory far better than re-reading, and it surfaces the small snags while they are still harmless. After that the technique is genuinely yours: faster than searching for it again, and reliable enough to drop into work that other people depend on.
Common mistakes
- Using IsEmpty on a formula cell and concluding the sheet is populated. IsEmpty asks whether the cell holds anything at all, and a formula counts — even one that shows nothing.
- Passing a multi-cell range to IsEmpty. It evaluates the first cell only and quietly reports on that, giving a confident wrong answer about the rest. CountA is the range-level test.
- Missing cells that contain a single space. Neither test treats " " as blank; if imported data might carry one, compare Trim(cell.Value) = "" instead.
- Testing only column A before deleting a row. A row can have an empty A and real data in D — CountA over the whole row is the check that prevents destroying it.
- Confusing VBA's IsEmpty with the worksheet
ISBLANKfunction. They are different tools with similar names; from VBA the equivalent is Application.WorksheetFunction.CountBlank or a direct IsEmpty test.
Frequently asked questions
What is the difference between IsEmpty and Value = ""?
IsEmpty is True only for a cell with nothing in it at all. Value = "" is also True for a cell holding a formula that returns an empty string. Pick based on whether a formula-blank should count.
How do I check whether an entire range is blank?
If Application.WorksheetFunction.CountA(ws.Range("A1:D100")) = 0 Then. CountA counts non-empty cells, so zero means every cell in the range is blank, and it needs no loop.
Is there an ISBLANK in VBA?
Not by that name. IsEmpty is the closest VBA equivalent; the worksheet function is reachable as Application.WorksheetFunction.CountBlank(rng) if you specifically want Excel's own definition.
Why does a cell that looks empty fail my test?
It almost certainly holds a formula returning "", or a single space left by an import. Check with Len(cell.Formula) and Len(cell.Value) — if they differ, a formula is present.
Other ways people ask this
People reach this page typing “check if a date is within a range excel”, “range function in excel vba”, “excel vba is empty” and “excel vba for each cell in range”, among other phrasings; whichever wording you used, the fix above is the one you want.
Why do people search for this in so many different ways?
Because the same task has many names. “check if a date is within a range excel”, “range function in excel vba”, “excel vba is empty” all point at the one operation explained on this page, which is why they all lead here.