+ Reply to Thread
Results 1 to 8 of 8

Iferror

  1. #1
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Iferror

    I just wondered what people's opinions were on the use of the IFERROR function. Pre 2007 I often used to warn people off widely using ISERROR as it can mask all kinds of problems and make workbooks quite hard to find problems in.

    I'm by no means saying that neither have their place and the greater simplicity of IFERROR over having to repeat your functions within an IF statement is welcome. I just think it could become overused when problems can be fixed further up the calculation chain.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Iferror

    I think that many factors come into play when deciding on the use of IFERROR.

    What is the purpose of the sheet? If the sheet is used as display/reporting only, then IFERROR is nice because it will display a more friendly message (or often no message) when an error occurs, rather than #N/A or whatever. If the sheet, however, is used for production and calculation on data, then leave the errors alone and resolve them at the source, if possible.

    When using IFERROR, follow the same rule as variable scope. Use the smallest "Scope" as possible. Don't just wrap your entire formula in an IFERROR function. Only use it on the parts that will actually return an error.
    For example: "=IFERROR(B7/G13,0)*M13", or "=IFERROR(Vlookup("Test",A:B,2,False),0) * C1"

    I try to take the same approach as error handling in VBA. It is necessary because errors will cause issues and frustration for the user, and you need to handle those errors and return a useful message to the user, or do a different calculation. But just as using On Error Resume Next in every sub or function is to be avoided, over using IFERROR is a bad practice.

    It is just another tool to use to get the job done. If the tool is not appropriate for the job, don't use it. It is like Duct Tape. Yes, it fixes a lot of things, but sometimes it is just a band-aid fix, is ugly, and some glue or a screwdriver is a better choice.
    Last edited by Whizbang; 10-26-2011 at 11:36 AM.

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Iferror

    I don't always use Duct Tape. Sometimes I reach for the No More Nails

    Dom

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Iferror

    I actually didn't notice there was an iferror until about a week ago.
    Is Iferror() that much easier than If(iserror())?

    Can we please get an Ifsum() function too? How about IfVlookup()?

    Maybe there is a subtle difference I'm not aware of.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Iferror

    It just means you can write:

    =IFERROR(VLOOKUP(blah blah),"")

    Rather than:

    =IF(ISERROR(VLOOKUP(blah blah)),"",VLOOKUP(blah blah))

    I don't know if it's more efficient but is simpler to write. I've also noticed more people using it as it's mentioned as a nice new function.

    Dom

  6. #6
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Iferror

    It is more efficient because it only calculates the VLOOKUP(blah blah)) part once.

  7. #7
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Iferror

    Here is another recent thread that discusses the use of IfError and If(IsError())

    http://www.excelforum.com/excel-prog...as-in-vba.html

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Iferror

    Quote Originally Posted by Whizbang View Post
    It is more efficient because it only calculates the VLOOKUP(blah blah)) part once.
    Logically that would be the case. Will check out that thread,

    Cheers,

    Dom

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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