RBT
RBT

Reputation: 25965

What is the equivalent of logical negation/not operator

I've to execute a piece of code written in Visual Basic for Applications (VBA) when the excel cell is not empty. I've written below piece of code so far:

Public Sub BindTitles(ByVal cell As Range)
    If IsEmpty(cell.Value) Then
        Application.EnableEvents = False
        'other code
    End If
End Sub

I want to invert the logical condition present in If statement. In C#, I use exclamation operator ! but when I put it in If block it gives below error:

Compile error:

Invalid or unqualified reference

Upvotes: 0

Views: 2327

Answers (1)

Kostas K.
Kostas K.

Reputation: 8508

The logical negation ! operator in VBA is Not:

If Not IsEmpty(cell.Value) Then '...

Upvotes: 1

Related Questions