0 votes
in VBA by Beginner (11 points)

There's said to use the IsEmpty() function to check if the content of a cell is empty.  However, I have a case where this test fails (that is, IsEmpty() returns False while the cell is empty).

IsEmpty(.Cells(currentRow, columnDict(dlgIconPopup))) = True returns False

.Cells(currentRow, columnDict(dlgIconPopup)) = "" returns True (which it should)

Why is IsEmpty() not catching ""?

 

 

1 Answer

0 votes
by Beginner (65 points)

This function returns true in any kind of void

'-----------------------------------------------------------------------------
' True if the argument is Nothing, Null, Empty, Missing or an empty string .
' http://blog.nkadesign.com/2009/access-checking-blank-variables/
'-----------------------------------------------------------------------------
Public Function IsBlank(arg As Variant) As Boolean
    Select Case VarType(arg)
        Case vbEmpty
            IsBlank = True
        Case vbNull
            IsBlank = True
        Case vbString
            IsBlank = LenB(arg) = 0
        Case vbObject
            IsBlank = (arg Is Nothing)
        Case Else
            IsBlank = IsMissing(arg)
    End Select
End Function

 

Welcome to wellsr Q&A
Ask any questions you have about VBA and Python and our community will help answer them. wellsr Q&A is the standalone question and answer platform for wellsr.com. If you have a question about one of our specific tutorials, please include a link back to the tutorial.

Getting Started
Register
VBA Cheat Sheets (On Sale Now)

Looking for something else? Hire our team directly through ourVBA Help page, instead.

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.

...