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. Excel for the web cannot create, run, or edit VBA macros. Open the workbook in the Excel desktop app to work with macros.
On this page8
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. A macro runs in the desktop app's VBA environment, not in the cell grid: the workbook has to be saved in a macro-enabled format such as .xlsm to keep the code, and your macro security settings — or a file that arrived from the internet — can block it until you trust it. Excel for the web cannot run VBA at all. The difference between a quick fix and a sheet you can trust is the extra minute you spend validating “excel vba isblank”. Start on a copy or a tiny sample, keep the affected blanks visible, and compare the result with the outcome you expected before you touch the real workbook. 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. The point is a workflow that saves repeating the same clicks every week, but the practical win is that someone else can open the file and understand what happened without asking you.
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. Run a new macro on a copy of the workbook first. Do not count on Undo to reverse what a macro changed; the saved copy is your way back.
In Google Sheets
Google Sheets does not run VBA. A macro written for Excel has to be rewritten in Google Apps Script (Extensions ▸ Apps Script), and an .xlsm file converted to Sheets keeps its cells but drops the code. 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 and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. The short version of “excel vba isblank”: paste the code, keep the workbook macro-enabled, trust the file only if you know where it came from, and test on a copy. Code that refers to the active sheet acts on whichever sheet is active, so check that before you run it.
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.