Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of "!=" in Excel VBA?

The problem is that != does not work as a function in excel vba.

I want to be able to use

If strTest != "" Then instead of If strTest = "" Then

Is there another approach to do this besides !=?

My function to mimic != is

Sub test()  Dim intTest As Integer Dim strTest As String  intTest = 5  strTest = CStr(intTest) ' convert  Range("A" + strTest) = "5"        For i = 1 To 10         Cells(i, 1) = i          If strTest = "" Then             Cells(i, 1) = i         End If      Next i   End Sub 
like image 658
What'sUP Avatar asked Jul 21 '12 20:07

What'sUP


People also ask

How do you say not equal to in VBA?

Not Equal is an operator in VBA which can also be termed as a negation operator, it is a logical function so the output returned by this function is either true or false, we know that equal operator is “=” this but not equal is “<>” in VBA so whatever the value we get from the equal operator we will get exact opposite ...


1 Answers

Because the inequality operator in VBA is <>

If strTest <> "" Then     ..... 

the operator != is used in C#, C++.

like image 177
Steve Avatar answered Sep 20 '22 16:09

Steve