+ Reply to Thread
Results 1 to 3 of 3

Fixing a divide by 0 error with iterative calculations

  1. #1
    Registered User
    Join Date
    03-07-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Fixing a divide by 0 error with iterative calculations

    Hello,

    I have a fairly large Excel file. The main output number is calculated using an iterative calculation. I have used VBA to automatically enable iterative calculations (although I am not positive of the proper maximum iterations and maximum change numbers to use). My Excel document uses dynamic data, however, and regularly still gives a divide by zero error. Users of the document are having issues.

    If I go to the cell in question, click on the formula bar, and click "Enter," the problem is solved. But, I can't figure out how to do that with VBA. I tried to record a macro, but that does not seem to work. Here is what I have tried:

    Please Login or Register  to view this content.
    (as you can guess, this cell SUMs two other cells)

    Thanks for the help.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: Fixing a divide by 0 error with iterative calculations

    Can you change the formula that produces the #DIV/0! error to test for the zero in the denominator and avoid the error?

    =IF(denominator=0, 0, numerator/denominator)

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,375

    Re: Fixing a divide by 0 error with iterative calculations

    You are probably going to have to upload a sample workbook, so we can actually see the different cell references, follow the circular logic, and possibly identify where the error is coming from.

    Until then, something to consider -- I've found it desirable whenever I set up an iterative calculation like that to have error traps somewhere in the loop to catch errors and other problems. In this case, you want an error trap associated with the given division formula that will catch the div by 0 error, feed a reasonable value to the next step in the calculation to allow the loop to continue.

+ 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