+ Reply to Thread
Results 1 to 4 of 4

Evaluate Sub-formula Only Once

  1. #1
    Registered User
    Join Date
    12-16-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Evaluate Sub-formula Only Once

    Hi,

    Is there any way to evaluate a subformula which appears more than once within a formula only once?

    For example, a common thing which I do is to replace an error value with some default like this:

    =IF(ISERROR(f()), 0, f())

    where f() is some excel formula.

    Is there a way to only evaluate f() once? I tried using named formulae but it seems not to work (at least, for UDFs it didn't).

    Alternatively, is there a function similar to the sql ISNULL() function to specify an alternative value if the value of a sub-formula is an error?

    Thanks
    Last edited by djk; 12-16-2010 at 07:16 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Evaluate Sub-formula Only Once

    Invest in Excel 2007/2010.

    It has an IFERROR function.

    For example, =IFERROR(yourfunction, "error message ... or "" ... or whatever")

    Or you could look at this approach:

    http://www.stutzman.org/index.php/20...for-excel-2003

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    12-16-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Evaluate Sub-formula Only Once

    That's great, thanks for your help

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Evaluate Sub-formula Only Once

    Prior to XL2007 you can ape IFERROR via a UDF.

    Alternatively if as implied in OP the output of the formula is a consistent data type (eg number) then you can also adopt an approach along the lines of:

    Please Login or Register  to view this content.
    here the f() formula [whatever it is - we assume non-UDF] is evaluated only once.

    for a text output with say default of Null you would use:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1