Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"