LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default Better way for writing IF statement ?

Hi;

Since it's the same variable myVar1 that I'm testing, I thought there might
be a way (documented or improvised) that could be applied in this situation.
Something like inserting: "." or " ," or ":=" or "/" or whatever!

I originally had a nested IF similar to yours, but realized then that one
is limited to a max of 9 tested conditions within the nested IF
(ocassionally. there're more conditions!). So, I switched to a single-line
IF, where applicable, regardless of the number of conditions.

In some situations, the nested IF is the preferable (if not the only) way to
do the tests, where for each satisfied condition(s), there're different
computational procedures to follow.

Back to my sample:
IF myVar1 = 1 And myVar1 < 100 And myVar1 < 25 And myVar1 <= Index Then
GoTo myLable

How about:

Select Case myVar1
Case = 1, < 100, < 25, <= Index
GoTo myLable
End Select

with the above commas (which represent OR) are replaced by AND (or something
equivelant) ?? I've done a dry run. It didn't work.

Regards.

"tony h" wrote:


Macropod is quite right but I wondered, Monir, whether there is more
behind the question. EG are you having to repeat this lots of times? If
so post some more description of the issue

Cheers


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=548020


 
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
NEED HELP WRITING IF STATEMENT bumblebug Excel Discussion (Misc queries) 5 October 7th 08 01:34 PM
Writing IF Statement Angie Excel Worksheet Functions 4 June 5th 07 10:10 PM
writing a statement newexceluser Excel Worksheet Functions 1 July 21st 06 10:15 PM
Help writing an IF statement cynichromantique Excel Worksheet Functions 6 April 1st 06 12:51 AM
need help in writing a statement susan hayes Excel Programming 3 September 28th 04 04:37 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"