ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AND/OR in Macro (https://www.excelbanter.com/excel-programming/403914-macro.html)

WLMPilot

AND/OR in Macro
 
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

Dan R.

AND/OR in Macro
 
If Me.OptionButton1 Or Me.OptionButton2 Then
MsgBox "both checked"
Else
MsgBox "none checked"
End If

--
Dan

On Jan 9, 8:51*am, WLMPilot
wrote:
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


John Bundy

AND/OR in Macro
 
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
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"WLMPilot" wrote:

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


JE McGimpsey

AND/OR in Macro
 
Take a look at the "And Operator" topic in VBA Help...

If OptionButton1.Value And OptionButton2.Value Then

....


In article ,
WLMPilot wrote:

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


Bernard Liengme

AND/OR in Macro
 
No, the use is more in keeping with natural languages:
If Myvar 0 And Myvar < 10 then ....
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"WLMPilot" wrote in message
...
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





All times are GMT +1. The time now is 06:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com