Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
this must be very easy, but I cannot figure it out the right way: I want an If statement that checks whether one or more cells contain specific values. Therefore I tried something like: if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then BLABLABLA etc. However, the OR doesn't work like this, but I cannot figure out how it should be done! Thanks for the help! Max |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Max,
In VB Sub mersible() If Range("A1").Value = 1 Or Range("A2").Value = 2 Then MsgBox ("Validated") Else MsgBox ("Not Validated") End If End Sub OIr as a worksheet formula:- =IF(OR(A1=1,A2=2),"Its true","Its not true") Mike "Max" wrote: Hi, this must be very easy, but I cannot figure it out the right way: I want an If statement that checks whether one or more cells contain specific values. Therefore I tried something like: if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then BLABLABLA etc. However, the OR doesn't work like this, but I cannot figure out how it should be done! Thanks for the help! Max |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks!
"Mike H" wrote: Max, In VB Sub mersible() If Range("A1").Value = 1 Or Range("A2").Value = 2 Then MsgBox ("Validated") Else MsgBox ("Not Validated") End If End Sub OIr as a worksheet formula:- =IF(OR(A1=1,A2=2),"Its true","Its not true") Mike "Max" wrote: Hi, this must be very easy, but I cannot figure it out the right way: I want an If statement that checks whether one or more cells contain specific values. Therefore I tried something like: if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then BLABLABLA etc. However, the OR doesn't work like this, but I cannot figure out how it should be done! Thanks for the help! Max |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Max
Standard syntax for using If Then statements is as follows If ......... Then dosomething Else do something else End If Or If ......... Then Do something ElseIf ........ Do something Else End If Depending on how many logical statements you have to check - you could also use the Selectt Case statement HTH "Max" wrote: Hi, this must be very easy, but I cannot figure it out the right way: I want an If statement that checks whether one or more cells contain specific values. Therefore I tried something like: if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then BLABLABLA etc. However, the OR doesn't work like this, but I cannot figure out how it should be done! Thanks for the help! Max |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mike,
thanks, I know about the if-statements. But I want to use OR statements, not only here, but in other parts as well and I thought they might be available in VB as well. Just as you can use them in excel, returning a Boolean value. Can you help me with this one? Thanks, Max "steve_doc" wrote: Hi Max Standard syntax for using If Then statements is as follows If ......... Then dosomething Else do something else End If Or If ......... Then Do something ElseIf ........ Do something Else End If Depending on how many logical statements you have to check - you could also use the Selectt Case statement HTH "Max" wrote: Hi, this must be very easy, but I cannot figure it out the right way: I want an If statement that checks whether one or more cells contain specific values. Therefore I tried something like: if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then BLABLABLA etc. However, the OR doesn't work like this, but I cannot figure out how it should be done! Thanks for the help! Max |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Max,
You can't use OR without IF and I gave you the VB version. Sub mersible() If Range("A1").Value = 1 Or Range("A2").Value = 2 Then MsgBox ("Validated") Else MsgBox ("Not Validated") End If End Sub Mike "Max" wrote: Hi Mike, thanks, I know about the if-statements. But I want to use OR statements, not only here, but in other parts as well and I thought they might be available in VB as well. Just as you can use them in excel, returning a Boolean value. Can you help me with this one? Thanks, Max "steve_doc" wrote: Hi Max Standard syntax for using If Then statements is as follows If ......... Then dosomething Else do something else End If Or If ......... Then Do something ElseIf ........ Do something Else End If Depending on how many logical statements you have to check - you could also use the Selectt Case statement HTH "Max" wrote: Hi, this must be very easy, but I cannot figure it out the right way: I want an If statement that checks whether one or more cells contain specific values. Therefore I tried something like: if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then BLABLABLA etc. However, the OR doesn't work like this, but I cannot figure out how it should be done! Thanks for the help! Max |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Mike H" wrote in message ... Max, You can't use OR without IF and I gave you the VB version. val1 = 17 val2 = 2 MsgBox val1 20 Or val2 0 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then
BLABLABLA MsgBox val1 20 Or val2 0 then BLABLABLA without IF please? Mike "Bob Phillips" wrote: "Mike H" wrote in message ... Max, You can't use OR without IF and I gave you the VB version. val1 = 17 val2 = 2 MsgBox val1 20 Or val2 0 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OK, I understand and the if statement already works,
Thank you Mike! Max "Mike H" wrote: Max, You can't use OR without IF and I gave you the VB version. Sub mersible() If Range("A1").Value = 1 Or Range("A2").Value = 2 Then MsgBox ("Validated") Else MsgBox ("Not Validated") End If End Sub Mike "Max" wrote: Hi Mike, thanks, I know about the if-statements. But I want to use OR statements, not only here, but in other parts as well and I thought they might be available in VB as well. Just as you can use them in excel, returning a Boolean value. Can you help me with this one? Thanks, Max "steve_doc" wrote: Hi Max Standard syntax for using If Then statements is as follows If ......... Then dosomething Else do something else End If Or If ......... Then Do something ElseIf ........ Do something Else End If Depending on how many logical statements you have to check - you could also use the Selectt Case statement HTH "Max" wrote: Hi, this must be very easy, but I cannot figure it out the right way: I want an If statement that checks whether one or more cells contain specific values. Therefore I tried something like: if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then BLABLABLA etc. However, the OR doesn't work like this, but I cannot figure out how it should be done! Thanks for the help! Max |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Max,
did you see Bob's example without use of 'If' another one - Dim bValid as Boolean bValid = Range("A1").Value = 1 Or Range("A2").Value = 2 Regards, Peter T "Max" wrote in message ... OK, I understand and the if statement already works, Thank you Mike! Max "Mike H" wrote: Max, You can't use OR without IF and I gave you the VB version. Sub mersible() If Range("A1").Value = 1 Or Range("A2").Value = 2 Then MsgBox ("Validated") Else MsgBox ("Not Validated") End If End Sub Mike "Max" wrote: Hi Mike, thanks, I know about the if-statements. But I want to use OR statements, not only here, but in other parts as well and I thought they might be available in VB as well. Just as you can use them in excel, returning a Boolean value. Can you help me with this one? Thanks, Max "steve_doc" wrote: Hi Max Standard syntax for using If Then statements is as follows If ......... Then dosomething Else do something else End If Or If ......... Then Do something ElseIf ........ Do something Else End If Depending on how many logical statements you have to check - you could also use the Selectt Case statement HTH "Max" wrote: Hi, this must be very easy, but I cannot figure it out the right way: I want an If statement that checks whether one or more cells contain specific values. Therefore I tried something like: if or(Sheets(1).Range("K36")16%, Sheets(1).Range("K37")16%) then BLABLABLA etc. However, the OR doesn't work like this, but I cannot figure out how it should be done! Thanks for the help! Max |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF statement inside a SUMIF statement.... or alternative method | Excel Worksheet Functions | |||
Reconcile Bank statement & Credit card statement & accounting data | Excel Worksheet Functions | |||
Embedding an OR statement in an IF statement efficiently | Excel Discussion (Misc queries) | |||
If statement or lookup statement not sure | Excel Worksheet Functions | |||
appending and IF statement to an existing IF statement | Excel Worksheet Functions |