Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 117
Default Using Or in an If statement

Can I write and If statement saying
"If citeria is matched or_
citeria is matched or_
citeria is matched then
do something

end if"

Can you use or instead of doing a bunch of else if?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default Using Or in an If statement

e.g.
=IF(OR(A1=1,A1=3,A1=7);1,0))
if you mean a formula
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 117
Default Using Or in an If statement

No I am trying to write it in VBA and I'm not really sure ho wto do that.

Thanks though

"Jarek Kujawa" wrote:

e.g.
=IF(OR(A1=1,A1=3,A1=7);1,0))
if you mean a formula

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default Using Or in an If statement

the answer to yr original question is yes

Sub sth

If cells(1,1).value = 1 or _
cells(1,1).value = 3 or _
cells(1,1).value = 7 Then

cells(1,2).value = "YES"

End if

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 117
Default Using Or in an If statement

that worked, thanks


"Jarek Kujawa" wrote:

the answer to yr original question is yes

Sub sth

If cells(1,1).value = 1 or _
cells(1,1).value = 3 or _
cells(1,1).value = 7 Then

cells(1,2).value = "YES"

End if

End Sub




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default Using Or in an If statement

The syntax is
IF(logical_test, value_if_true, [value_if_false])

Replace "logical_test" with citeria is matched or citeria is matched or
citeria is matched


Jase wrote:

Can I write and If statement saying
"If citeria is matched or_
citeria is matched or_
citeria is matched then
do something

end if"

Can you use or instead of doing a bunch of else if?


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
Sum if statement with a left statement Eric D Excel Discussion (Misc queries) 4 July 23rd 08 05:31 PM
Can an If statement answer an If statement? M.A.Tyler Excel Discussion (Misc queries) 2 June 24th 07 04:14 AM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 March 1st 06 12:00 AM
If statement and Isblank statement Rodney C. Excel Worksheet Functions 0 January 18th 05 09:39 PM
Help please, IF statement/SUMIF statement Brad_A Excel Worksheet Functions 23 January 11th 05 03:24 PM


All times are GMT +1. The time now is 06:58 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"