Consulting

Results 1 to 4 of 4

Thread: Solved: excel's IF function

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Solved: excel's IF function

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location
    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!!!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •