PDA

View Full Version : Solved: excel's IF function



philfer
10-27-2009, 05:12 AM
I have been writing functions in Excel VBA and was thinking about the IF function.

I was wondering if anyone had any insight into how it is written. I was thinking that it must be quite huge in order to deal with all the different types of conditions a user could use and the different types of return values or ranges the user could specify

Does any know

Cheers
Phil

Bob Phillips
10-27-2009, 05:45 AM
I wouldn't think so, it would parse each condition and test whether it is TRUE or FALSE, and then returns the final result. All of the testing of the conditions would be code shared by many other aspects of the language.

philfer
10-27-2009, 05:52 AM
yes, but each condition could be a string comparison, a number or logical comparison, a range.

Each one could be = or > or >= and so on and so on

The code would surely have to be able to contend with every possible type of input and every possible type of operator.

It could even be something like =IF((A1+B1)/C1*D1>E1,"true","false")

The potential inputs and outputs could be massive and the code would have to deal with every possibility.

It boggles my mind.....but perhaps that says more about me!!!

Bob Phillips
10-27-2009, 06:28 AM
But I am saying I don't think that is part of IF, it is a fundamental function in the OS, a comparison, which IF taps into.