IsEmpty is a worksheet function that is used to find out whether a given cell reference or a range of cells are empty or not since it is a worksheet function so to use it in VBA we use Application. Worksheet method in VBA to use this function, this function comes under the logical lists of function and returns true if the reference is empty.

## VBA IsEmpty Function

VBA IsEmpty is a logical function that tests whether selected is empty or not. Since it is a logical function it will return the results in Boolean values i.e. either TRUE or FALSE.

If the selected cell is empty it will return TRUE or else it will return FALSE.

In this article, we will show you how to use “ISEMPTY” function in VBA to check the cells using VBA codes.

### What Does ISEMPTY Function Do in VBA?

Often empty cells frustrate us to work efficiently in the worksheet. Finding the blank cells isn’t the hardest but if empty cells are hiding them in the middle of the data then it takes a toll to find them.

To find the empty cells in excel we have the function called “ISBLANK” as worksheet function but in VBA it is called “ISEMPTY”.

This works similarly to the worksheet function “ISBLANK”. Now take a look at the below formula of the “ISEMPTY” function.

As we can see in the above image it returns the result as Boolean i.e. TRUE or FALSE.

### Examples of ISEMPTY Function in VBA

The following are the examples of IsEmpty in VBA.

#### Example #1

Now we will see the first practical example of “ISEMPTY”. For this take a look at the below image of the worksheet.

Now we will apply excel VBA ISEMPTY function to test all these.

**Step 1: **Define the variable **as Boolean**.

**Code:**

Sub IsEmpty_Example1() Dim K As Boolean End Sub

**Step 2: **For this variable assign the value through VBA **ISEMPTY** function.

**Code:**

Sub IsEmpty_Example1() Dim K As Boolean K = IsEmpty( End Sub

**Step 3: **Expression is nothing but what is the cell we are testing. Now we are testing cell **A1 cell**.

**Code:**

Sub IsEmpty_Example1() Dim K As Boolean K = IsEmpty(Range("A1").Value) End Sub

**Step 4: **Show the value of this variable in the VBA **Msgbox**.

**Code:**

Sub IsEmpty_Example1() Dim K As Boolean K = IsEmpty(Range("A1").Value) MsgBox K End Sub

Run this code to check the result.

Since there is a value in the cell A1 we got the result as FALSE.

Now I will change the cell reference from **A1 to A5.**

**Code:**

Sub IsEmpty_Example1() Dim K As Boolean K = IsEmpty(Range("A5").Value) MsgBox K End Sub

Run this code to see the result.

We got the result as TRUE the referenced cell A5 is actually empty cell so we got the result as “TRUE”.

Now I will test the **cell A8.**

**Code:**

Sub IsEmpty_Example1() Dim K As Boolean K = IsEmpty(Range("A8").Value) MsgBox K End Sub

Run this code to see the result.

Oh!!! Hold on…

We got the result as FALSE even though there is no value in the cell A8.

Now the question is it an error result from the formula “ISEMPTY”?.

No… Absolutely No!!!

When I tried examining the cell A8 actually there is a space character inside the cell which is not easy to see with bare eyes.

So the conclusion is even Space is considered as a character in excel and VBA language.

#### Example #2 – Combination of VBA ISEMPTY with IF Condition

Actually, the real usage of the function “ISEMPTY” is admirable when we use it with other logical functions.

Especially when we use it with IF condition we can derive many useful results from it.

For this demonstration take a look at the below example.

In the Status column if the “PF Status” column is empty we need the value as “No Update” and if there is any value we need the values as “Collected Updates”.

Remember here we don’t need the default result of TRUE or FALSE. We need our own results here, to have our own results we need to use Excel VBA ISEMPTY with IF condition.

**Step 1: **Open **IF** condition.

**Code:**

Sub IsEmpty_Example2() If End Sub

**Step 2: **Inside the IF condition open **ISEMPTY function**.

**Code:**

Sub IsEmpty_Example2() If IsEmpty( End Sub

**Step 3: **The first logical test is **cell B2 value** is empty or not.

**Code:**

Sub IsEmpty_Example2() If IsEmpty(Range("B2").Value) Then End Sub

**Step 4: **If the logical test is TRUE i.e. if the cell is empty we need the result as “**No Update**” in cell C2.

**Code:**

Sub IsEmpty_Example2() If IsEmpty(Range("B2").Value) Then Range("C2").Value = "No Update" End Sub

**Step 5: **If the logical test is FALSE we need the result in cell C2 as “**Collected Updates**”.

**Code:**

Sub IsEmpty_Example2() If IsEmpty(Range("B2").Value) Then Range("C2").Value = "No Update" Else Range("C2").Value = "Collects Updates" End If End Sub

Ok, we are done.

Run the code to get the result.

We got the result as **“Collected Updates”** because we have the non-empty cell in B2.

Now similarly apply the code for other cells to test.

**Code:**

Sub IsEmpty_Example2() If IsEmpty(Range("B2").Value) Then Range("C2").Value = "No Update" Else Range("C2").Value = "Collects Updates" End If If IsEmpty(Range("B3").Value) Then Range("C3").Value = "No Update" Else Range("C3").Value = "Collected Updates" End If If IsEmpty(Range("B4").Value) Then Range("C4").Value = "No Update" Else Range("C4").Value = "Collected Updates" End If End Sub

Run this code to have the results.

In cell C3 we got the result as **“No Update”** because there is no value in cell B3 i.e. Empty Cell. Since the logical formula returned TRUE we got the respective result.

#### Example #3 – Alternative to VBA ISEMPTY Function

We have an alternative to ISEMPTY function, without applying the excel VBA ISEMPTY function we can actually test the cell.

For an example look at the below code.

**Code:**

Sub IsEmpty_Example3() If Range("B2").Value = "" Then Range("C2").Value = "No Update" Else Range("C2").Value = "Collected Updates" End If End Sub

The line of code **Range(“B2″).Value = ” ” **means whether the cell B2 cell is equal to empty or not.

Double Quotes (“ ”) represents an empty cell or not if the empty result is TRUE or else FALSE.

### Recommended Articles

This has been a guide to VBA ISEMPTY function. Here we learned how to use VBA ISEMPTY function in Excel and Combination of IsEmpty with If condition along with some practical examples and downloadable excel template. Below are some useful excel articles related to VBA –

- 3 Courses
- 12 Hands-on Projects
- 43+ Hours
- Full Lifetime Access
- Certificate of Completion