Excel ISBLANK vs IsEmpty (Uses and Comparison)

Get FREE Advanced Excel Exercises with Solutions!

In this article, we will learn about ISBLANK vs. IsEmpty in Excel. Microsoft Excel is a popular tool for organizing and managing data. When you need to check for empty cells, you can utilize the ISBLANK and IsEmpty functions in Excel.

When you need to know if a cell is still empty/blank, you can use the ISBLANK function in an Excel worksheet. But in the case of VBA, you need to use the IsEmpty function for the same purpose.

Here, we will try to find the uses and differences between the ISBLANK vs. IsEmpty functions.

Applying ISBLANK function


Introduction to Excel ISBLANK Function

Summary:

When a cell is empty, the ISBLANK function returns TRUE, and when a cell is not empty, it returns FALSE. This function takes one argument. This is an Excel Function.

summary of ISBLANK

Function Objective:

Returns a boolean value representing if the cell is empty or not.

Syntax:

ISBLANK(Value)
  • Value: This is the cell that the function is trying to evaluate if it is blank or not.

Return Value:

  • TRUE: If the cell is blank.
  • FALSE: If the cell is not blank.

Introduction to VBA IsEmpty Function

Summary:

The VBA IsEmpty function returns TRUE when a cell is empty, and FALSE when a cell is not empty. It also takes one argument. This is an exclusive function for VBA.

Syntax of IsEmpty

Function Objective:

Returns a boolean value representing if the cell is empty or not.

Syntax:

IsEmpty(Expression)
  • Expression: Refers to a variant which might be a numeric or string

Return Value:

  • TRUE: If the cell is empty
  • FALSE: If the cell is not empty.

When Do We Need to Use ISBLANK and IsEmpty Functions?

When we are working in an Excel worksheet we can use the ISBLANK function, and when we are writing a code in VBA we can use the IsEmpty function to check if a cell is blank or not.


How to Use ISBLANK Function in Excel

  • The ISBLANK function is used to determine whether a cell is blank or not.
  • To do this, select cell D5 and enter the formula given below. Then drag the Fill Handle icon from D5 to D14. Then drag the Fill Handle icon from D5 to D14.
=ISBLANK(C5)

Applying ISBLANK function

  • However, if we see the dataset clearly we can see that the C9 cell is blank but the result is False.
  • It’s because it is not completely blank. It contains an empty string. That’s why the ISBLANK function returned False.

cell contains an empty string


How to Use IsEmpty Function in Excel VBA

1. VBA IsEmpty to Check Empty Cell

  • In this method, we will use the IsEmpty function and write a VBA code to check if the cell is empty or not.
  • To do this, go to Developer >> Visual Basic.

Opening visual basic

  • Then, in the Visual Basic window Insert a module.

Inserting a module

  • After that, write the code given below and click on the Run icon.
Sub CheckCell()
Dim ws As Worksheet
Dim cell As Range
' Set the worksheet object
Set ws = ThisWorkbook.Worksheets("ISEMPTY")
' Loop through each cell in the range C5 to C14
For Each cell In ws.Range("C5:C14")
' Write "True" if the cell is not empty, otherwise write "False"
cell.Offset(0, 1).Value = IsEmpty(cell)
Next cell
End Sub

running the code

  • Now we can see the result has been updated.
  • If the cell is empty we will see TRUE, otherwise FALSE. But again the C9 cell contains an empty string. So, the IsEmpty function returned False.

cell containing a string


2. VBA IsEmpty to Check Variable Declaration

  • The IsEmpty function also can be used to check variable declaration.
  • Here we will use the IsEmpty function and check whether the variable is initialized or not. For this purpose, write the code given below in the Module.
Sub Check_Variable()
   Dim Exp As Variant
   'Test if the variable has been initialized
   If IsEmpty(Exp) = True Then
      MsgBox "The Variable has been declared but not initialized."
   Else
      MsgBox "The Variable has been declared and initialized."
   End If
End Sub

Running the code after declaring the variable

  • Here we only declared the variable. So now if we run the code it should show “The Variable has been declared but not initialized”.

Obtained result

  • Now we need to initialize the variable and then run the code.
Sub Check_Variable()
   Dim Exp As Variant
   'Test if the variable has been initialized
   Exp = 10
   If IsEmpty(Exp) = True Then
      MsgBox "The Variable has been declared but not initialized."
   Else
      MsgBox "The Variable has been declared and initialized."
   End If
End Sub

Running the code after initializing

  • As a result, the message box shows “The Variable has been declared and initialized”.

Obtained result


Main Difference Between ISBLANK and IsEmpty Functions

  • The main difference between the ISBLANK and IsEmpty function is that the ISBLANK function is an Excel Function and the IsEmpty function is a VBA function.
  • The IsEmpty function checks if the cell is empty (variable not initialized) or if the cell is not empty (variable initialized). As it is a VBA function, obviously you may use the function in macro code to find the expected output.
  • The ISBLANK also does the same. It also checks if the cell is empty or not.

Frequently Asked Questions

1. What can I use instead of ISBLANK?

You can also use COUNTBLANK instead of ISBLANK for empty cells. ‘=COUNTBLANK(Cell)‘ will return 1 if blank, and 0 if not blank.

2. What’s the opposite of the ISBLANK function?

The opposite of the ISBLANK function in Excel is the NOT function. You can use ‘NOT(ISBLANK(cell))‘.


Download Practice Workbook

You can download the practice workbook from here.


Conclusion

In this article, we tried to cover a comparative analysis of ISBLANK vs. IsEmpty functions in Excel. This will clear the misconception one has regarding these two functions. Using the described methods, you can use the ISBLANK and IsEmpty functions to determine whether a cell is blank or not.


Related Articles

Md Sakibul Hasan Nahid
Md Sakibul Hasan Nahid

Hello I am Sakibul Hasan Nahid. I have completed my BSc. in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology. I take a great interest in learning about new technologies and sharing my ideas and thoughts on them with others. Please do reach out to me if you have any queries or recommendations.

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo