AND/OR in Macro

  • Thread starter Thread starter WLMPilot
  • Start date Start date
W

WLMPilot

Do I follow the same format in a macro as I do in a spreadsheet for the
following?

IF(AND(test1, test2))

If not, what would be the correct way to test the value of multiple fields.

I wanted to test the value of optionbutton1 and optionbutton 2 and if either
were TRUE, THEN...........

Thanks,
Les
 
If Me.OptionButton1 Or Me.OptionButton2 Then
MsgBox "both checked"
Else
MsgBox "none checked"
End If
 
If test1 or test2 = true then...is valid, but generally better to be more
specific, If test1=true or test2=true then..
both of these are valid
 
Take a look at the "And Operator" topic in VBA Help...

If OptionButton1.Value And OptionButton2.Value Then

....
 
No, the use is more in keeping with natural languages:
If Myvar > 0 And Myvar < 10 then ....
best wishes
 

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