ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Condition Statement (https://www.excelbanter.com/excel-programming/284842-condition-statement.html)

Stel

Condition Statement
 
Wonder if you can help me on this:

I'm writing more than 4 conditional statement in one loop:

If =Bear Then
If =Blue Then return
If =Red Then return
If <Bear Then
If =Yellow Then return
.....

The problem is that =Red condition keeps returning true even under <Bear
i.e. 'Red' keeps showing up no matter what
Why is that?





Auric__

Condition Statement
 
On Tue, 9 Dec 2003 00:46:05 -0800, Stel wrote:

Wonder if you can help me on this:

I'm writing more than 4 conditional statement in one loop:

If =Bear Then
If =Blue Then return
If =Red Then return
If <Bear Then
If =Yellow Then return
....

The problem is that =Red condition keeps returning true even under <Bear
i.e. 'Red' keeps showing up no matter what
Why is that?


Your problem is unclear. We need more info - what is equal to Red? To
Bear? To Blue and Yellow? Can you perhaps post the actual code
containing this chunk so we can see it in context?
--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
There is no XXXXXXX place for censorship!

Stel

Condition Statement
 
If cell(1,2)=bear Then
If cell(1,3)=Blue Then return
ElseIf cell(1,3)=Red Then return
ElseIf cell (1,2) <Bear Then
If cell(1,3)=Yellow Then return
.....
Can this explain better?

Thank you very much!



No Name

Condition Statement
 
Try to structure your argument in a logical way using
indentation. In this way you will find it easier to see
what is wrong with your logic, and you'll be able to
explain it to someone else as well:

If Cells(1, 2) = Bear Then
If Cells(1, 3) = Blue Then
Return
Else
If Cells(1, 3) = Red Then
Return
End If
End If
Else
If Cells(1, 2) < Bear Then
If Cells(1, 3) = Yellow Then
Return
End If
End If
End If


-----Original Message-----
If cell(1,2)=bear Then
If cell(1,3)=Blue Then return
ElseIf cell(1,3)=Red Then return
ElseIf cell (1,2) <Bear Then
If cell(1,3)=Yellow Then return
....
Can this explain better?

Thank you very much!


.


Tom Ogilvy

Condition Statement
 
If cell(1,2)=bear Then
If cell(1,3)=Blue Then return ElseIf cell(1,3)=Red Then return
ElseIf cell (1,2) <Bear Then
If cell(1,3)=Yellow Then return
End if

You are trying to use a single line if statement but are using multiple
lines. It either all has to be on one line or use a multiple line
construct. In the above, the outer IF is multiline and the second level IF
is single line.

If cell(1,2)=bear Then
If cell(1,3)=Blue Then
return
ElseIf cell(1,3)=Red Then
return
End if
ElseIf cell (1,2) <Bear Then
If cell(1,3)=Yellow Then return
End if

Is another alternative.

or
if cell(1,2)=bear and cell(1,3) = Blue or cell(1,3)=Red then
return
elseif cell(1,2)<bear and cell(1,3)=Yellow then
return
End if

--
Regards,
Tom Ogilvy


"Stel" wrote in message
...
If cell(1,2)=bear Then
If cell(1,3)=Blue Then return
ElseIf cell(1,3)=Red Then return
ElseIf cell (1,2) <Bear Then
If cell(1,3)=Yellow Then return
...
Can this explain better?

Thank you very much!






All times are GMT +1. The time now is 05:10 PM.

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