REAL-TIME

VBA Projects

Full Access with Source Code
  • Designed and Developed by PNRao

  • Full Access with VBA Source Code

  • Well Commented Codes Lines

  • Creative and Professional Design

Effortlessly
Manage Your Projects

120+ Project Management Templates

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Share Post

We can use VBA to check if a cell is blank and run the remaining statements. Sometimes, we need to determine and make sure a particular range is not empty before proceeding to the next statements. This example will help you to know how to check if a cell or a range is blank or not using Excel VBA. This can be used in Excel 2003,2007,2010,2013.

VBA code to check if a cell is blank – Syntax

Here is the example Excel VBA Syntax to check if a cell is blank or not. The below macro will check whether a Range A1 is blank or not.

If Cells(1, 1) = "" Then
 ... Statements to execute if the Cell is Empty 
Else
 ...statements to execute if Cell is not Blank.
end if

VBA code to check if a cell is blank – Example

Here is the example macro to check if a cell is blank or not. The below macro will show a message box based on the Cell.

Sub vba_code_to_check_if_a_cell_is_blank()
    If Cells(1, 1) = "" Then
        MsgBox "Cell is Blank"
    Else
        MsgBox "Cell is not blank"
    End If
End Sub

VBA code to check if a cell is blank – Better Example: Avoid Empty Spaces

Sometimes, A cell or rang looks blank and we notice that the condition is failing. It is because of the empty spaces in the cell. So, whenever you want to check if a cell is empty, you can trim the Cell value and check it.

Sub vba_code_to_check_if_a_cell_is_blank()
     'use trim to avoide blank spaces
    If Trim(Cells(1, 1)) = "" Then
        MsgBox "Cell is Blank"
    Else
        MsgBox "Cell is not blank"
    End If
End Sub

VBA code to check if a cell is blank – Instructions

Please follow the below step by step instructions to test this Example VBA Macro codes:

  • Step 1: Open a New Excel workbook
  • Step 2: Press Alt+F11 – This will open the VBA Editor (alternatively, you can open it from Developer Tab in Excel Ribbon)
  • Step 3: Insert a code module from then insert menu of the VBE
  • Step 4: Copy the above code and paste in the code module which have inserted in the above step
  • Step 5: Enter some sample data at range A1 to check if the cell is blank or not using VBA.
  • Step 6: Now press F5 to execute the code or F8 to debug the Macro to check the if Range A1 is blank or not
Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Save Up to 85% LIMITED TIME OFFER
Project Management Templates

All-in-One Pack
120+ Project Management Templates

Essential Pack
50+ PM Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project
Management Template
Ultimate Resource
Management Template
Project Portfolio
Management Templates
Categories: VBALast Updated: January 19, 2015

One Comment

  1. Jorge Cabral March 12, 2017 at 6:01 AM

    What about if the cell as a formula, but the result is ” or zero?

Leave A Comment