PC Review


Reply
Thread Tools Rate Thread

AND/OR in Macro

 
 
WLMPilot
Guest
Posts: n/a
 
      9th Jan 2008
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
 
Reply With Quote
 
 
 
 
Dan R.
Guest
Posts: n/a
 
      9th Jan 2008
If Me.OptionButton1 Or Me.OptionButton2 Then
MsgBox "both checked"
Else
MsgBox "none checked"
End If

--
Dan

On Jan 9, 8:51*am, WLMPilot <WLMPi...@discussions.microsoft.com>
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

 
Reply With Quote
 
John Bundy
Guest
Posts: n/a
 
      9th Jan 2008
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

 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      9th Jan 2008
Take a look at the "And Operator" topic in VBA Help...

If OptionButton1.Value And OptionButton2.Value Then

....


In article <1B0D1F61-2E23-4DFA-A7C8-(E-Mail Removed)>,
WLMPilot <(E-Mail Removed)> 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

 
Reply With Quote
 
Bernard Liengme
Guest
Posts: n/a
 
      9th Jan 2008
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" <(E-Mail Removed)> wrote in message
news:1B0D1F61-2E23-4DFA-A7C8-(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Microsoft Excel Worksheet Functions 3 30th Oct 2009 11:41 AM
::: Sort macro with empty lines at the end. ::: Macro de tri avec lignes vide en bas. infojacques@gmail.com Microsoft Excel Discussion 2 5th Jul 2007 11:40 AM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor karll@swfab.com Microsoft Excel Programming 2 30th Mar 2007 07:48 PM
Run Macro On Open event for report and SetValue Macro has wierd error ThompsonJessical@yahoo.com Microsoft Access Macros 2 2nd Aug 2005 05:51 PM
Start Macro / Stop Macro / Restart Macro Pete Microsoft Excel Programming 2 21st Nov 2003 05:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:34 AM.