Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Does an if statement calculate both the true and false?
I have a spreasheet, with 40000+ rows.
I have an if statement which is basically if(A1="OK",0,long and complex formula). Almost all instances are "OK" with a few exceptions requiring the complex, time consuming part of the formula. Does excel calculate that part of the formula even for cells which are "OK" and hence taking up loads of time, or does it ignore it knowing it doesn't need to return it? Thanks! Chris |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Does an if statement calculate both the true and false?
Hi,
VBA evaluates both parts of the formula, the Excel worksheet IF function only evaluates one part of the formula depending on whether the logical condition is TRUE or FALSE Tushar Mehta has an excellent tutorial on the IF function here http://www.tushar-mehta.com/publish_...f_function.htm -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "chriswilko" wrote: I have a spreasheet, with 40000+ rows. I have an if statement which is basically if(A1="OK",0,long and complex formula). Almost all instances are "OK" with a few exceptions requiring the complex, time consuming part of the formula. Does excel calculate that part of the formula even for cells which are "OK" and hence taking up loads of time, or does it ignore it knowing it doesn't need to return it? Thanks! Chris |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Does an if statement calculate both the true and false?
Excel does not appear to calculate the false part if the true part is valid.
I tried the formula: =IF(A1<0,0,trial(A1)) where trial is the UDF: Function trial(r As Range) As Double For i = 1 To 1000000 trial = trial + r.Value Next trial = trial + 1 End Function I tried several numbers in A1 and the result was instantaneous unless I entered 0 -- Gary''s Student - gsnu201001 "chriswilko" wrote: I have a spreasheet, with 40000+ rows. I have an if statement which is basically if(A1="OK",0,long and complex formula). Almost all instances are "OK" with a few exceptions requiring the complex, time consuming part of the formula. Does excel calculate that part of the formula even for cells which are "OK" and hence taking up loads of time, or does it ignore it knowing it doesn't need to return it? Thanks! Chris |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Does an if statement calculate both the true and false?
On Mar 31, 5:13*pm, chriswilko
wrote: I have a spreasheet, with 40000+ rows. I have an if statement which is basically if(A1="OK",0,long and complex formula). Almost all instances are "OK" with a few exceptions requiring the complex, time consuming part of the formula. Does excel calculate that part of the formula even for cells which are "OK" and hence taking up loads of time, or does it ignore it knowing it doesn't need to return it? Thanks! Chris Hi Chris, If the value is "OK", it will check for the TRUE value and exit the function... so no need to worry about the complex satement incase the value is "OK" Ratheesh |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Does an if statement calculate both the true and false?
"chriswilko" wrote:
I have an if statement which is basically if(A1="OK",0,long and complex formula). [....] Does excel calculate that part of the formula even for cells which are "OK" and hence taking up loads of time, or does it ignore it knowing it doesn't need to return it? Unlike a real function, the IF expression evaluates only the parts that are necessary; at least, in Excel 2003. You can validate that fact for your revision of Excel with the following. =if(A1,myUDF(1),myUDF(2)) where A1 is a 0 or 1, and myUDF is: Function myUDF(x) myUDF = x MsgBox "myUDF " & x End Function ----- original message ----- "chriswilko" wrote: I have a spreasheet, with 40000+ rows. I have an if statement which is basically if(A1="OK",0,long and complex formula). Almost all instances are "OK" with a few exceptions requiring the complex, time consuming part of the formula. Does excel calculate that part of the formula even for cells which are "OK" and hence taking up loads of time, or does it ignore it knowing it doesn't need to return it? Thanks! Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
TRUE/FALSE STATEMENT | Excel Discussion (Misc queries) | |||
TRUE/FALSE function in IF statement | Excel Worksheet Functions | |||
Two TRUE to one FALSE statement | Excel Worksheet Functions | |||
If Statement returns true when false? | Excel Discussion (Misc queries) | |||
How can I make a True or False statement a certain color when usi. | Excel Worksheet Functions |