I'm sorry if this is a stupid question, but does the (Excel VBA) AND function checks EVERY single condition in it then proceed, or stops at the first FALSE condition and not checks the other? I'd like to know for optimization purposes and found nothing about it on the web so far.. Thanks in advance!
Example: If InStr(txt, "abc") > 0 And InStr(txt, "xyz") > 0 Then
so if "abc" not found in the txt variable (gives 'false'), then will the macro check the "xyz" too or skip the rest conditions
It appears that VBA keeps on going:
Sub ANDTest()
If f1() And f2() Then MsgBox "X"
End Sub
Public Function f1() As Boolean
f1 = False
End Function
Public Function f2() As Boolean
MsgBox "in f2"
f2 = False
End Function

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With