IsEmpty problem in visual basic code in module

lah21

New Member
Joined
Feb 2, 2015
Messages
5
I am working on some code in an excel module using IsEmpty. I copied some code from an example and the problem still exists. The code is


Sub TestCellA1()
'Test if the value is cell A1 is blank/empty
If isempty(Range("A1").Value) = True Then
MsgBox "Cell A1 is empty"
End If
End Sub

Note that isempty is all lowercase and not as it should be, I have searched all of the worksheets listed under the project viewer Microsoft Excel Objects, and there is no code under any of the worksheets. I have also checked all of the worksheets for occurrences IsBlank and IsEmpty and there are none.

I am at a lost as to what else to look at.

Thanks
Louis
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
? Right click on the function and select definition. Where does that take you in the object browser?
Also, try VBA.IsEmpty or VBA.Information.IsEmpty

VBA Code:
Sub TestCellA1()
    'Test if the value is cell A1 is blank/empty
    If VBA.Information.IsEmpty(Range("A1").Value) = True Then
        MsgBox "Cell A1 is empty"
    End If
End Sub
 
Upvote 0
Do you get any error messages, when you run the code?
If so what?
 
Upvote 0
Thank you for the quick replies. First neither adding VBA. or VBA.Information solved the problem. 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. This what happens in my original code.

LAH21
 
Upvote 0
I modified the code so that the IF tested of False instead of True, and changed messages accordingly. The new code is

Sub TestCellA1()
'Test if the value is cell A1 is blank/empty
If VBA.Information.isempty(Range("A1").Value) = False Then
MsgBox "Cell A1 is not empty"
Else
MsgBox "Cell A1 is empty"
End If
End Sub

In this instance it does not fall through to the Else statement and the message "Cell A1 is not empty" is created. So with the original code and the modified code gives the same message.
 
Upvote 0
Do you have anything named isempty in the workbook?
 
Upvote 0
Now this is interesting. I cleared cell A1 and reran the modified code. This the the If statement fell through to the Else statement and the correct message was created that the cell was empty,

It appears that the IsEmpty is working even though it is all lower case.

LAH21
 
Upvote 0
OK, did not know how to do it.

There is no other occurrence of isempty or IsEmpty that I can find. I searched all of the workbooks and all of the code in this project. The only occurrences are of IsEmpty in commented out statements.
 
Upvote 0
What about named ranges?

Do you have any add-ins installed?
 
Upvote 0
I've always wondered about the occasional forced lower/upper case on some of my variables. Never could figure out the source of it. Have you searched all libraries in your object browser for IsEmpty? Just curious if there is another function in some other reference. Does your project compile?
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,721
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top