+ Reply to Thread
Results 1 to 16 of 16

Prevent #DIV/0 error Code Needed

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    988

    Prevent #DIV/0 error Code Needed

    Hi Everyone,

    I am needing to eliminate the dreaded #DIV/0 error - I am trying to use it in conjunction with this code

      =IFERROR(INDEX(O7:AH19,,MATCH(AI$2,V$4:AH$4,0))-INDEX(O7:AH19,,MATCH(AI$2,V$4:AH$4,0)-1))/INDEX(O7:AH19,,MATCH(AI$2,O$4:AH$4,0)-1),"")
    This is also returning an error - Says "You have entered too few arguments for this function"

    Any Ideas on this issue???

    John
    Last edited by JJFletcher; 09-06-2015 at 08:59 PM.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Prevent #DIV/0 error Code Needed

    I think you just had a misplaced closing ) in there:

    =IFERROR(INDEX(O7:AH19,,MATCH(AI$2,V$4:AH$4,0))-INDEX(O7:AH19,,MATCH(AI$2,V$4:AH$4,0)-1)/INDEX(O7:AH19,,MATCH(AI$2,O$4:AH$4,0)-1),"")
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Prevent #DIV/0 error Code Needed

    Tony Valko ,

    This took away the error - thanks so much...

    Is there code that will eliminate the error without hard coding the individual cells for the results?

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Prevent #DIV/0 error Code Needed

    Quote Originally Posted by JJFletcher View Post
    Tony Valko ,

    This took away the error - thanks so much...
    Good deal!

    Is there code that will eliminate the error without hard coding the individual cells for the results?
    Having read the other replies in the thread I don't know why you'd want to do this.

    However, it can probably be done using a VBA procedure but I'm not much of a programmer so someone else will need to help you with it.

  5. #5
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Prevent #DIV/0 error Code Needed

    Thanks for your replies.....

    This is a piece of code I found - but it does not seem to work very well

     Sub DelDiv0()
    ' Removes the #DIV/0! values from all cells in the selected
    ' range and replaces them with a zero value
     Dim Cel As Range
     For Each Cel In Selection
     If IsError(Cel.Value) Then
     If Cel.Value = CVErr(xlErrDiv0) Then Cel.Value = 0
     End If
     Next Cel
    End Sub
    The #DIV/0! still propagates the cells

    Any thoughts

    John

  6. #6
    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
    53,048

    Re: Prevent #DIV/0 error Code Needed

    What do you mean?
    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

  7. #7
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Prevent #DIV/0 error Code Needed

    Is there a way to code the worksheet so that all errors are taken care of if they occur in the cells?

    John

  8. #8
    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
    53,048

    Re: Prevent #DIV/0 error Code Needed

    If any part of that formula produces an error, the IFERROR will catch it

  9. #9
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Prevent #DIV/0 error Code Needed

    Agreed, yet the code is entered directly into the cell - I was wondering if a Macro could be created to perform the function without putting it directly into the cell...

  10. #10
    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
    53,048

    Re: Prevent #DIV/0 error Code Needed

    Why would you not want to put it in the cell?

  11. #11
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Prevent #DIV/0 error Code Needed

    To eliminate having to put the code into each cell which is ranging on average 300 cells,

    Putting the code into the cell desired to control the error when dividing 0/0 I can do... thought there is possible a Macro that can do the work !
    Last edited by JJFletcher; 09-06-2015 at 10:59 PM.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,810

    Re: Prevent #DIV/0 error Code Needed

    How have used it?

    You select a range and then run the macro: it does not automatically resolve the errors.
    Last edited by JohnTopley; 09-07-2015 at 03:11 PM.

  13. #13
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Prevent #DIV/0 error Code Needed

    I would like the code to automatically function when the page loads... the above Macro

    =IFERROR((INDEX(O7:AH19,,MATCH(AI$2,V$4:AH$4,0))-INDEX(O7:AH19,,MATCH(AI$2,V$4:AH$4,0)-1))/INDEX(O7:AH19,,MATCH(AI$2,O$4:AH$4,0)-1),"")
    is loaded into each cell in the column...

  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,810

    Re: Prevent #DIV/0 error Code Needed

    You cannot load a macro into a cell.

  15. #15
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Prevent #DIV/0 error Code Needed

    Hi John,

    Thanks for your response...

    So a Macro would not be able to locate #DIV/0 in the spreadsheet and cause the cell to be blank?

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Prevent #DIV/0 error Code Needed

    Quote Originally Posted by JJFletcher View Post

    So a Macro would not be able to locate #DIV/0 in the spreadsheet and cause the cell to be blank?
    A #DIV/0! error is the result generated by a formula. If you don't want the formula result to be the #DIV/0! error then you would typically write the formula to account for those errors and return an alternative result.

    You said the formula suggested in post 2 solved the #DIV/0! error problem.

    If there are no more #DIV/0! errors then why do you need a macro to remove them?

    So, what exactly are you wanting to do?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Error checking code that will prevent over-writing of a workbook when saving to PDF
    By mike_vr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-02-2012, 10:11 AM
  2. [SOLVED] Error using code to prevent editing of data with forms
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-13-2012, 07:56 PM
  3. Error in code to skip cells between entry fields - help needed!
    By rache66 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2010, 07:57 AM
  4. Prevent a Saving Error
    By JamesT1 in forum Excel General
    Replies: 7
    Last Post: 08-26-2008, 01:55 PM
  5. Validation Needed To Prevent Deletion
    By swordswinger710 in forum Excel General
    Replies: 6
    Last Post: 05-01-2008, 08:57 AM
  6. Prevent #VALUE error
    By Ducatisto in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-27-2008, 09:36 AM
  7. [SOLVED] how to prevent code running when in a worksheet code
    By Corey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-13-2006, 04:00 AM
  8. Prevent Error Message
    By phil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-26-2005, 03:06 PM

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