+ Reply to Thread
Results 1 to 6 of 6

User Defined Function for #DIV/0! errors

  1. #1
    Registered User
    Join Date
    03-15-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    User Defined Function for #DIV/0! errors

    Hello,

    I'm new to post, but I've been reading this and many other excel forums for the last 6 months.

    I am trying to create a function that will return whatever value is input as long as the value is not #DIV/0!
    I don't want to use IFERROR because I still need to see if there are any reference or value errors, but I also don't want to see a bunch of #DIV/0!s all over the place.

    This is what I've got so far but when I try to use it, it will result in a #VALUE! error unless the input value is #DIV/0!, in which case it returns 0...like I want it to.

    Please Login or Register  to view this content.
    Any help would be much appreciated.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: User Defined Function for #DIV/0! errors

    You could build the following in your formula to look for that specific error. #div/0 has an error code 2...
    =ERROR.TYPE(A1)

    As far as your VB code is concerned, not too VB-savy here (yet) so this may be a stupid question, but should the Div0 have a "/" in it?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    03-15-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: User Defined Function for #DIV/0! errors

    Oh, the Div0 in my function is just the name of the function, so it doesn't have to follow naming conventions.

    The problem with the ERROR.TYPE() function is that I'd have to add much more. The numbers I'm dividing are pretty large SUMIFS, so I don't want to have to repeat functions.
    Using ERROR.TYPE(), it'd have to be something like:
    IF(ERROR.TYPE(SUMIFS(A:A,B1,C:C,D1,E:E,F1,G:G,H1)/SUMIFS(I:I,B1,C:C,D1,E:E,F1,G:G,H1))=2,0,SUMIFS(A:A,B1,C:C,D1,E:E,F1,G:G,H1)/SUMIFS(I:I,B1,C:C,D1,E:E,F1,G:G,H1))

    I'm just trying to make these as simple as possible so that if I have to hand off this project to anyone else, fixing/modifying stuff will be as easy as possible.

    Thanks for commenting!! :D

    Edit: I think I see the Div0 that you're talking about. xlErrDiv0 is the VB code for #DIV/0!
    Last edited by zoudazou; 03-15-2012 at 04:53 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: User Defined Function for #DIV/0! errors

    See if this does what you're looking for:
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-15-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: User Defined Function for #DIV/0! errors

    Update:

    I can now get it to display what is input as long as it's NOT #DIV/0!, which is close(er?) to what I wanted:

    Please Login or Register  to view this content.
    The same thing happens when substituting the xlErrDiv0 with the string "#DIV/0!"

  6. #6
    Registered User
    Join Date
    03-15-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: User Defined Function for #DIV/0! errors

    That's perfect! Thanks so much, WHER!! :D

+ 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