Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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?




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default 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!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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!


  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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!


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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!




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
Multiple condition if statement Tel Excel Discussion (Misc queries) 4 June 25th 09 02:35 PM
IF statement...And condition Rich D Excel Discussion (Misc queries) 1 January 4th 08 03:50 PM
3 logical condition if statement Mikehughes Excel Worksheet Functions 3 July 19th 06 01:59 PM
Blanks as a condition of a statement Stuck on Blanks New Users to Excel 2 November 23rd 05 12:24 AM
Condition Statement Django Excel Discussion (Misc queries) 5 August 26th 05 06:59 PM


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