If ..Then statements

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If you have 2 conditions (2 IF statements) and both must be met, or we go to
the
'else' statement, what is the code for this?
Your help will be appreciated.
 
If MyVar1 = True And MyVar2 = False Then
MsgBox "First Condition Satisified"
Else
MsgBox "Do Something Else"
End If
 
How does this work exactly - here is my code-hopefully you can see
what I'm trying to do here. This is part of the'open' procedure. Where
would I write myvar code or define myvar?
Thanks for your help

Sheets("MENU").Select

If ActiveWorkbook.FullName = "C:\TMR\TMR.xls" Then

Sheets("MENU").Select
Else
Sheets("End").Select
Range("A1").Select
MsgBox "Contact Psyfactor Ltd for Licence", vbOKOnly, "TMR"
Application.ActiveWorkbook.Save
Application.Quit

End If

If Dir("C:\WINDOWS\system32\unicode.txt") = vbNullString Then
Sheets("End").Select
Range("A1").Select
MsgBox "Contact Psyfactor Ltd for Licence", vbOKOnly, "TMR"
Application.ActiveWorkbook.Save
Application.Quit
End If



End Sub
 
I think this is what you mean

If ActiveWorkbook.FullName <> "C:\TMR\TMR.xls" Or _
Dir("C:\WINDOWS\system32\unicode.txt") = vbNullString Then
MsgBox "Contact Psyfactor Ltd for Licence", vbOKOnly, "TMR"
Application.ActiveWorkbook.Save
Application.Qui
Else
Sheets("MENU").Select
End If

But you may want to draw up a decison table for the 4 options
FullName <> AND Dir = Nul
FullName <> AND Dir <> Null
FullName = AND Dir = Nul
FullName = AND Dir <> Null
to check it out

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top