excel - How are `IF` and `AND` statements evaluated in VBA? -
this question has answer here:
in java or c#, and
statements evaluated left right. if first condition not true, second condition not evaluated. useful if second condition cause java.lang.arrayindexoutofboundsexception
.
i have similar case in excel-vba application. have if statement such:
if condition1 = false , cellelement - 1 <> "" then
...
it throws vba - run time error 1004 'application defined or object defined error'
, if condition1
false.
my question is, vba evaluate second condition in , statement, if first condition false?
my current work around ugly, works:
dim b boolean if condition1 = false b = false else b = cellelement - 1 <> "" if b then...
thank you!
Comments
Post a Comment