Equality & Inequality Operator in Excel VBA

By Hemanta Sundaray on 2021-09-05

Equality operator

In VBA, the assignment operator (=) also acts as the equality operator. We can check whether two values are equal using the = operator.

? 10 = 11

False

Similarly, we also have an inequality operator.

Inequality operator

<> is the inequality operator in VBA.

? 10 <> 20

True

We can use both the equality and inequality operator with the string data type as well.

? "hello world" = "hello world"

True

It is important to note that case sensitivity matters while comparing string values.

? "Hello World" = "hello world"

False
? "Hello" <> "hello"

True

Join the Newsletter