{ 2 Intelligent Comments }

HOWTO: Excel – Detect an Empty Cell

Microsoft Excel Logo

Check For An Empty Cell in Microsoft Excel

This HOWTO explains how you can detect an empty cell and provide an error message if the cell is empty in a Microsoft Excel worksheet.

It should work for all versions of Excel.

The cell we are checking for an empty value will be checked every time a user makes a change to the cell.

Download a sample excel file here

In this example, that cell will be cell C5.

Use Microsoft Excel’s VBA to detect the empty cell

  1. Open the worksheet you want to detect the empty cell in.
  2. Take a note of the cell you want to check for an empty value. e.g. C5 in this example
  3. Open the the Visual Basic Editor by clicking Tools > Macro > Visual Basic Editor or press ALT+F11 on the keyboard
  4. On the left pane, right click the sheet that contains the cell you want to check and click ‘View Code
  5. On the right pane, enter or copy/paste the following code:
  6. Private Sub Worksheet_Change(ByVal Target As Range)


    If IsEmpty(Cells(5, 3)) Then MsgBox (“Empty Cell – Please ensure there is a value in all grey cells.  Thanks”)


    End If


    End Sub

  7. The above code will check cell C3 on my worksheet which is highlighted in grey in the screen shot below.

    Excel Worksheet Example:  Check grey cell for an empty value

  9. Change the your code as follows:
    • Enter your cell number in place of the Cells(5,3) reference.
      • For example, Cells(5,3) = Cell C3.  The 5 is the row number and the 3 is the column number.
    • For MsgBox, enter your own custom message between the quotes.
  10. Close the Visual Basic Editor by clicking the X in the top right corner of the window
  11. Test your worksheet.  It should look like the below screenshot after you attempt to clear the value from cell C3.


Microsoft Excel:  Sample error message after detecting an empty cell


Wow, 2 Comments! We've got a conversation going now. Join the discussion below!

  1. subject says:

    Link eхchange is nothing elsе but it is jսst placing the other person’s website
    link on your page at suitable pⅼace and other person will
    also do similɑr for үou.

  2. […] HOWTO: Excel – Detect an Empty Cell – Proposed Solution – Validate in Microsoft Excel if a cell is left empty or blank using this simple piece of macro code in the built in Visual Basic interface […]

Leave a Reply