Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
long IF statement with lots of OR's
Hi
Is there a smarter way to write this kind of code ? If InputParameter1 = "A" And (InputParameter2 = "X" Or InputParameter2 = "Y" Or InputParameter2 = "Z" and so on) Then [...] My intuition would go for something like this: If InputParameter1 = "A" And InputParameter2 In ("X", "Y", "Z", and so on) but that doesn't seem to be correct. Any ideas ? René |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
long IF statement with lots of OR's
Can you be sure InputParameter2 will be one character. If so then
if inputparameter1 = "A" and Instr("XYZ",Inputparameter2) then if it is more complex than that Dim res as Variant res = Application.Match(InputParameter2,Array("XXX","YYY ","ZZZ"),0) if inputparameter1 = "A" and not iserror(res) then Regards, Tom Ogilvy "René" wrote in message ... Hi Is there a smarter way to write this kind of code ? If InputParameter1 = "A" And (InputParameter2 = "X" Or InputParameter2 = "Y" Or InputParameter2 = "Z" and so on) Then [...] My intuition would go for something like this: If InputParameter1 = "A" And InputParameter2 In ("X", "Y", "Z", and so on) but that doesn't seem to be correct. Any ideas ? René |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
long IF statement with lots of OR's
You could put your parameters in a certain cell and reference that, as
you suggested. For instance: =IF(AND(A1="xyz", ISERROR(FIND(<the reference to your input parameter, <the reference to your list of acceptable values))=FALSE)=TRUE, 1, 0) Please let me know if that doesn't work. Mark --- Mark Bigelow mjbigelow at hotmail dot com http://hm.imperialoiltx.com *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Long If Statement | Excel Worksheet Functions | |||
Excel cut and paste row takes a long time. Lots of formulas. | Excel Discussion (Misc queries) | |||
very long statement | Excel Discussion (Misc queries) | |||
IF statement too long | Excel Discussion (Misc queries) | |||
Long IF Statement | Excel Discussion (Misc queries) |