Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default if statements with AND or OR condition criteria


Hi guys,

Something simple but I can't get the syntax right IN VBA. I would like
to have an IF statement in which it will test two values at ONCE. Rather
then have an IF statement to test one value and another IF statement to
test another value inside the first IF statement.

I know that I can do it in Java, but I just can't do it in VBA, even in
Excel - you can use the AND(if(criteria), if(criteria)).

Pls help.


--
philwongnz
------------------------------------------------------------------------
philwongnz's Profile: http://www.excelforum.com/member.php...o&userid=26283
View this thread: http://www.excelforum.com/showthread...hreadid=399296

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default if statements with AND or OR condition criteria

if myVar1 = "ok" _
and myVar2 = "do it now" then
'both are true
else
'at least one is false.
end if

===
and in excel, I bet you'd use:

=if(and(criteria1,criteria2), ...



philwongnz wrote:

Hi guys,

Something simple but I can't get the syntax right IN VBA. I would like
to have an IF statement in which it will test two values at ONCE. Rather
then have an IF statement to test one value and another IF statement to
test another value inside the first IF statement.

I know that I can do it in Java, but I just can't do it in VBA, even in
Excel - you can use the AND(if(criteria), if(criteria)).

Pls help.

--
philwongnz
------------------------------------------------------------------------
philwongnz's Profile: http://www.excelforum.com/member.php...o&userid=26283
View this thread: http://www.excelforum.com/showthread...hreadid=399296


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default if statements with AND or OR condition criteria

Try something like

If (criterion1) And (criterion2) Then



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"philwongnz"
wrote
in message
...

Hi guys,

Something simple but I can't get the syntax right IN VBA. I
would like
to have an IF statement in which it will test two values at
ONCE. Rather
then have an IF statement to test one value and another IF
statement to
test another value inside the first IF statement.

I know that I can do it in Java, but I just can't do it in VBA,
even in
Excel - you can use the AND(if(criteria), if(criteria)).

Pls help.


--
philwongnz
------------------------------------------------------------------------
philwongnz's Profile:
http://www.excelforum.com/member.php...o&userid=26283
View this thread:
http://www.excelforum.com/showthread...hreadid=399296



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
IF statements with multiple criteria LWilson Excel Worksheet Functions 2 October 23rd 09 04:15 PM
Multiple criteria IF statements? Eán[_2_] Excel Worksheet Functions 2 April 9th 09 09:59 AM
Count Unique with criteria condition Spencer Hutton Excel Worksheet Functions 1 January 12th 09 06:35 PM
condition statements Arlene Excel Worksheet Functions 1 April 21st 05 01:47 AM
Assign ID based on condition(criteria) changeable[_11_] Excel Programming 1 November 7th 04 02:42 PM


All times are GMT +1. The time now is 03:27 AM.

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"