The Problem (Q-score 21, ranked #8th of 95 in the VBA Core archive)
The scenario as originally posted in 2010
I have an object and within it I wanna check if some properties is set to false, like:
If (not objresult.EOF) Then
'Some code
End if
But somehow, sometimes objresult.EOF is Empty, and how can I check it?
IsEmptyfunction is for excel cells onlyobjresult.EOF Is Nothing– returnEmptyobjresult.EOF <> null– returnEmptyas well!
Why community consensus is tight on this one
Across 95 VBA Core entries in the archive, the accepted answer here holds elite answer (top 10 %%) status — meaning voters are unusually aligned on the right fix.
The Verified Solution — elite answer (top 10 %%) (+44)
8-line VBA Core pattern (copy-ready)
How you test depends on the Property’s DataType:
| Type | Test | Test2 | Numeric (Long, Integer, Double etc.) | If obj.Property = 0 Then | | Boolen (True/False) | If Not obj.Property Then | If obj.Property = False Then | Object | If obj.Property Is Nothing Then | | String | If obj.Property = "" Then | If LenB(obj.Property) = 0 Then | Variant | If obj.Property = Empty Then |
You can tell the DataType by pressing F2 to launch the Object Browser and looking up the Object. Another way would be to just use the TypeName function:MsgBox TypeName(obj.Property)
Error-handling details to lift with the snippet
This answer wires error flow through MsgBox / Err.Description. Keep that intact: stripping it to “make it cleaner” removes the signal you’ll need when the macro fails silently on a user machine.
When to Use It — vintage (14+ years old, pre-2013)
A top-10 VBA Core pattern — why it still holds up
Ranks #8th of 95 in the VBA Core archive. The only pattern ranked immediately above it is “Implementing String.Format() in VB6” — compare both if you’re choosing between approaches.
What changed between 2010 and 2026
The answer is 16 years old. The VBA Core object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.