I prefer using

If Len(Trim(Cells(i, 1).Value))=0 Then Msgbox "Empty"
Answer from Siddharth Rout on Stack Overflow
🌐
Reddit
reddit.com › r/vba › isempty function not working in macro
r/vba on Reddit: IsEmpty function not working in Macro
June 10, 2017 -

I have multiple lines in my macro where I am checking to see if the current cell is empty or not. One of the lines works great. Two do not. I have copied the code for the two that don't from the one that does and it still isn't working. I've been stepping through the code line by line and I watch it not execute and I can't figure out where I'm going wrong. I also tried the Googles but no results there seemed to match my problem. Basically, regardless of the value in the active cells, the code always skips straight to "Else", even if one cell is empty and one is not. I have copied this exact code into a separate macro that was just this code and it worked fine. Why on earth would it not work here?

I Trim the cell to get rid of any potential whitespace characters. I'm sure there are more efficient ways to do this but, alas, I am not a code wizard yet. Bool1 and Bool2 are created and initialized to False earlier in the code. Also, the line that works uses the exact same IF statement setup, just with different values. Any help would be greatly appreciated.

Here is the snippet

ActiveCell.Value = Trim(ActiveCell.Value)

If IsEmpty(ActiveCell.Value) = True Then

'cell empty

bool1 = False

Else

'cell has x

bool1 = True

End If

ActiveCell.Offset(0, 1).Select

ActiveCell.Value = Trim(ActiveCell.Value)

If IsEmpty(ActiveCell.Value) = True Then

'cell empty

bool2 = False

Else

'cell has x

bool2 = True

End If

Discussions

Excel blank cells not empty
I encounter sometimes in Excel 2016 and 2019 worksheets blank cells that are counted as non empty in the right part of the task bar. VBA function IsEmpty() confirms they are not empty and COUNTA() counts them. More on learn.microsoft.com
🌐 learn.microsoft.com
8
1
October 9, 2022
VBA IsEmpty Function not working properly
Hi, I have a database of our clients, and the columns are arranged in the following way A B C D E F G H I J K ID NAME PHONE ADDRESS CITY STATE ZIP WEBSITE E-MAIL/CONTACT FORMS INDUSTRY STATUS I have the following macro, which works great. It basically loops through the database and... More on mrexcel.com
🌐 mrexcel.com
3
0
June 15, 2018
Excel blank cells not empty
I encounter sometimes in Excel 2016 and 2019 worksheets blank cells that are counted as non empty in the right part of the task bar. VBA function IsEmpty() confirms they are not empty and COUNTA() counts them. More on answers.microsoft.com
🌐 answers.microsoft.com
8
1
October 9, 2022
IsEmpty function not working in Macro

well... frankly, it means the cells you're working with aren't empty. i suggest you double-check that you're testing the cells you think you are.

set a breakpoint after the line "ActiveCell.Offset(0, 1).Select", then hit CTRL+G when the program breaks to bring up the Immediate Window. in that window, type "? ActiveCell.Address" and hit enter to see what cell you're actually looking at, then verify that it's empty onscreen. additionally, you can type "? IsEmpty(ActiveCell.Value)" or just "? ActiveCell.Value" and see what pops up.

hope this helps - happy debugging!

More on reddit.com
🌐 r/vba
12
3
June 10, 2017
🌐
MrExcel
mrexcel.com › forums › question forums › excel questions
IsEmpty problem in visual basic code in module | MrExcel Message Board
April 29, 2020 - When VBA.IsEmpty or VBA.Information.IsEmpty is used, IsEmpty apereas normally, but as soon as you click outside of the statement, it becomes all lowercase. I add an "Else" option to the If statement to display a message box indicating the cell was not empty. When the code is executed there are no error messages and the "If" statement fails and the message that the cell is not empty appears.
🌐
Excel Forum
excelforum.com › excel-programming-vba-macros › 366970-isempty-returns-false-in-empty-cells.html
IsEmpty() Returns False in empty cells [SOLVED]
April 29, 2005 - > Occasionally when I use IsEmpty to see if a cell contains data like > "IsEmpty(Cells(x,y))" it returns "False" when there is nothing there. I've · > tested the cell with Len(Cells(x,y)) and it returns 0. Does anyone know why · > this happens or how to get around it? > Thanks, > John Hutchins ... IsEmpty(), while it seems to work for really empty cells, is meant to determine if a variable has been initialized.
🌐
Microsoft Learn
learn.microsoft.com › en-us › office › vba › language › reference › user-interface-help › isempty-function
IsEmpty function (Visual Basic for Applications) | Microsoft Learn
September 13, 2021 - Dim MyVar, MyCheck MyCheck = IsEmpty(MyVar) ' Returns True. MyVar = Null ' Assign Null. MyCheck = IsEmpty(MyVar) ' Returns False. MyVar = Empty ' Assign Empty. MyCheck = IsEmpty(MyVar) ' Returns True. ... Have questions or feedback about Office VBA or this documentation?
🌐
DokuWiki
nolongerset.com › empty-in-vba
Working with Empty in VBA
September 7, 2023 - Sub MyRoutine(MyParam As Variant) If IsEmpty(MyParam) Then Throw "MyParam cannot be empty" End Sub · For more information about Guard Clauses and Throwing Errors in VBA, see the related articles: ... Guard clauses are one of my favorite low-friction defensive programming tools. ... Introducing a frictionless alternative to Err.Raise. ... Ben Clothier posted a great, succinct explanation in the comments section of An Article About Nothing:
🌐
DEV Community
dev.to › trpricesoftware › vba-how-to-if-else-and-checking-for-empty-strings-1oh8
VBA How-To: If/Else and Checking For Empty Strings - DEV Community
July 1, 2020 - It specifically says that IsEmpty() only returns True if a variable is not initialized or explicitly set to Empty. If you notice in my first example I declare stringVar as a string because I am used to programming in strongly typed languages ...
Top answer
1 of 5
1

would it be possible for somebody to explain what these cells effectively contain, why they are considered as not empty when they appear as blank and seem to contain nothing [...] and how they could have been generated?

My explanations could be more clear if I could publish the files, but I do not know how to do it.

The cells probably contain the null string ("") as a constant.

One way to create this is to enter the formula ="" into A1, copy A1, then paste-special-value back into A1.

Then CODE(A1) returns #VALUE, COUNTA(A1) returns 1, ISBLANK(A1) returns FALSE, VBA IsEmpty([a1]) returns False, and Asc([a1]) raises a VBA error ("invalid argument")

The cell is not considered empty because in Excel, "empty" means no value (constant or formula).


I'm sure that guess is correct. But for a dispositive answer, yes, it would be good to provide a simple Excel file that demonstrates the problem.

Upload the Excel file to a file-sharing website, and post the download URL in a response here.

I like box.net/files; others like dropbox.com. You might like onedrive.live.com because it uses the same login as this forum. But IMHO, if you use onedrive, be sure the download URL does not allow others to edit the file. That avoids accidental (as well as purposeful) changes. (I'm all thumbs. sigh)

2 of 5
0

Thanks for taking care

I loaded the test file in my Dropbox account Jacques SIMONNET (******@laposte.fr) in a folder named "Empty" that I shared readonly with Microsoft Community .

Is that OK or do I need to share it with a more precise address?

Best regards.

Find elsewhere
🌐
Statology
statology.org › home › vba: how to use “if not blank”
VBA: How to Use "If Not Blank"
March 17, 2023 - You can use Not IsEmpty in VBA to check if a cell is not blank.
🌐
Wellsr
wellsr.com › vba › 2016 › excel › use-isempty-vba-to-check-if-cell-is-blank
Use IsEmpty VBA to Check if Cell is Blank - wellsr.com
June 16, 2016 - As I mentioned in my IsNumeric VBA Tutorial, it’s a good practice to check if your cells are empty before applying certain VBA functions. Let’s take a look at some examples to see what I mean. Sub IsEmptyExample1() If IsEmpty(Range("A2")) = False Then 'Cell A2 is not blank MsgBox "Cell A2 is not empty" Else 'Cell A2 is blank MsgBox "Cell A2 is empty" End If End Sub
🌐
Wall Street Mojo
wallstreetmojo.com › home › all blogs › vba resources › vba isempty
VBA IsEmpty | How to Use VBA IsEmpty Function? (Examples)
December 23, 2024 - VBA IsEmpty is a logical function ... empty or not. Since it is a logical function, it will return the results in Boolean values, i.e., TRUE or FALSE. If the selected cell is empty, it will return TRUE, or else it will return FALSE. This article will show you how to use the ISEMPTY function in VBA to check the cells using VBA codes. Often empty cells frustrate us from working efficiently ...
🌐
MrExcel
mrexcel.com › forums › question forums › excel questions
VBA IsEmpty Function not working properly | MrExcel Message Board
June 15, 2018 - Dim LastRow As Long Dim i As Long, j As Long 'Find the last used row in a Column: column A in this example With Worksheets("Tracker") LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row End With MsgBox (LastRow) 'first row number where you need to paste values in Sheet1' With Worksheets("Contact Form To Send") j = .Cells(.Rows.Count, "A").End(xlUp).Row End With For i = 2 To LastRow With Worksheets("Tracker") If InStr(.Cells(i, 9).Value, "http") And IsEmpty(Cells(i, 11)) Then .Cells(i, 2).Copy Destination:=Worksheets("Contact Form To Send").Range("A" & j) .Cells(i, 9).Copy Destination:=Worksheets("Contact Form To Send").Range("B" & j) j = j + 1 End If End With Next i I am new to VBA, I have tried different iterations based on different things I saw online such as: IsEmpty(Range("K" & i).Value) and even IsEmpty(Cells(i, 11)) = True.
🌐
Ozgrid
forum.ozgrid.com › ozgrid free excel/vba help forum › help forums › excel general
If IsEmpty returning False Positive - Excel General - OzGrid Free Excel/VBA Help Forum
February 27, 2012 - Not seeing your data, I can't be certain, but I strongly suspect all your 'Or's should actually be 'And's (or the 'Or's need to be nested, but I would advise against making the entire thing more complicated): ... If IsEmpty(ActiveCell.Offset(0, 1)) And ActiveCell <> "OF" AND ActiveCell <> "SP" AND ActiveCell <> "RP" Then
🌐
Trump Excel
trumpexcel.com › home › excel vba › check if cell is empty (isempty function)
VBA Check IF Cell is Empty (using ISEMPTY Function)
March 18, 2024 - While using the ISEMPTY function is a perfectly fine way to do this, let me also show you another way to check whether a cell is empty or not using VBA. Below is the VBA code that compares the value in the target cell with an empty string. If the cell is blank, it shows a message box saying “Cell is Empty”; else, it shows a message box saying “Cell is not Empty”. Sub CheckIfCellIsEmpty() Dim targetCell As Range Dim ws As Worksheet 'Set the worksheet and target cell Set ws = ThisWorkbook.Sheets("Sheet1") Set targetCell = ws.Range("A1") 'Comparing with an empty string If targetCell.Value = "" Then MsgBox "Cell is Blank" Else MsgBox "Cell is not Blank" End If End Sub
🌐
TechOnTheNet
techonthenet.com › excel › formulas › isempty.php
MS Excel: How to use the ISEMPTY Function (VBA)
The ISEMPTY function returns FALSE ... (ie: is not empty). See also the ISBLANK function (worksheet function). Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000 ... The ISEMPTY function can only be used in VBA code in Microsoft ...
Top answer
1 of 5
1

would it be possible for somebody to explain what these cells effectively contain, why they are considered as not empty when they appear as blank and seem to contain nothing [...] and how they could have been generated?

My explanations could be more clear if I could publish the files, but I do not know how to do it.

The cells probably contain the null string ("") as a constant.

One way to create this is to enter the formula ="" into A1, copy A1, then paste-special-value back into A1.

Then CODE(A1) returns #VALUE, COUNTA(A1) returns 1, ISBLANK(A1) returns FALSE, VBA IsEmpty([a1]) returns False, and Asc([a1]) raises a VBA error ("invalid argument")

The cell is not considered empty because in Excel, "empty" means no value (constant or formula).


I'm sure that guess is correct. But for a dispositive answer, yes, it would be good to provide a simple Excel file that demonstrates the problem.

Upload the Excel file to a file-sharing website, and post the download URL in a response here.

I like box.net/files; others like dropbox.com. You might like onedrive.live.com because it uses the same login as this forum. But IMHO, if you use onedrive, be sure the download URL does not allow others to edit the file. That avoids accidental (as well as purposeful) changes. (I'm all thumbs. sigh)

2 of 5
0

Thanks for taking care

I loaded the test file in my Dropbox account Jacques SIMONNET (******@laposte.fr) in a folder named "Empty" that I shared readonly with Microsoft Community .

Is that OK or do I need to share it with a more precise address?

Best regards.

🌐
Excel Insider
excelinsider.com › home › our blog › excel vba › how to check if an array is empty in excel vba (3 ways)
How to Check if an Array Is Empty in Excel VBA (3 Ways) - Excel Insider
July 26, 2025 - ➧ The LoadStudentNames macro assigns the values from the worksheet range A2:A11 into the array variable studentArray. ➧ The IsEmpty function tests if studentArray has been initialized or assigned. If not, it returns True, meaning the array is empty (no data loaded).
🌐
ExcelMojo
excelmojo.com › home › vba › vba isempty
VBA IsEmpty Function in Excel - Syntax, Examples, How to Use?
July 2, 2025 - The principal task of the VBA IsEmpty function is to ascertain whether a particular variable has been initialized. By doing this, it helps to prevent the occurrence of runtime errors that can ensue when an uninitialized variable is utilized. Thus, the function is a significant asset in preventing possible execution errors. ... Learn to automate workflows, build smarter spreadsheets with VBA, and streamline data tasks using real-world examples—all in one powerful Excel VBA bundle.