function - retornar - ¿Cuál es el equivalente de "!=" En Excel VBA?
retornar valor function vba excel (4)
En VBA, el operador != Es el operador Not , así:
If Not strTest = "" Then ...
¡El problema es que != No funciona como una función en excel vba.
Quiero poder usar
If strTest != "" Then lugar de If strTest = "" Then
¿Hay otro enfoque para hacer esto además de != ?
Mi función para imitar != Es
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
Intenta usar <> lugar de != .
Porque el operador de desigualdad en VBA es <>
If strTest <> "" Then
.....
el operador != se usa en C #, C ++.
Solo una nota. Si quiere comparar una cadena con "" , en su caso, use
If LEN(str) > 0 Then
o incluso solo
If LEN(str) Then
en lugar.