Link to home
Start Free TrialLog in
Avatar of trbaze
trbaze

asked on

If else statement

I'm trying to write an if else statement in which the action would perform if two conditions where true.
example:
If result = 2, and time = 3, then
 
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

in VBA:


If result = 2  and time = 3  then

Open in new window

Avatar of trbaze
trbaze

ASKER

Is that the way it is actually written?  So that both conditions must return true on the if part of the statement.  Not just one.
yes, the  <condition 1> AND <condition 2> will return true only if both conditions return true.
more compelte verion:

If result = 2  and time = 3  then
'do action1
else
' do action2
end if
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Theres some other ways.
If you just happen to care, while we're point out .net and VBA.

Excel uses an AND function.  IF(AND(result=2,time=3),"Was true","Was False")

In VBA you can implement an AND by nested IFs

If Result = 2 then
  if time = 3 then
    'both were true
  end if
end if