ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Using Or in an If statement (https://www.excelbanter.com/excel-discussion-misc-queries/212837-using-if-statement.html)

jase

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?

Jarek Kujawa[_2_]

Using Or in an If statement
 
e.g.
=IF(OR(A1=1,A1=3,A1=7);1,0))
if you mean a formula

jase

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


Jarek Kujawa[_2_]

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


jase

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



Bob I

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?




All times are GMT +1. The time now is 01:04 AM.

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