+ Reply to Thread
Results 1 to 7 of 7

#DIV/0! replace error message with the number 0.

  1. #1
    Registered User
    Join Date
    09-02-2020
    Location
    Albany, NY
    MS-Off Ver
    2016
    Posts
    4

    Question #DIV/0! replace error message with the number 0.

    I am trying to help a colleague who has a workbook with 130 tabs.

    She wants to set a rule to display 0 instead of #DIV/0 when ever there is division by 0. this rule should apply to all pages and cells.

    It would be like the auto replace function in word that changes a dash into the longer dash.

    I have seen how to use IFERROR is functions, but hse does not want to rework 130 tabs worth of calculations.

    Any suggestions?

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: #DIV/0! replace error message with the number 0.

    If it is a simple enough formula, you can use vba to loop through each sheet and change the formulas. More detail would be required to help out. Also read the yellow banner at the top of the screen.

  3. #3
    Registered User
    Join Date
    09-02-2020
    Location
    Albany, NY
    MS-Off Ver
    2016
    Posts
    4

    Re: #DIV/0! replace error message with the number 0.

    Using VBA to loop through 130 tabs is an interesting idea. Might you be able to show a sample of this? I have not seen the workbook so I do not know the complexity of the formulas. Additionally, I don't even know if the formulas are the same on each sheet.

    I'm guessing that each field would have to be looked at to see if its a formula and modify it to something like: ISERROR([formula],0)

    since there are 1047576xXFD cells on each tab and 130 tabs, this would be no easy task and probably take quite a long time to process.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: #DIV/0! replace error message with the number 0.

    I can't give you a sample, you have to supply the sample.

    There may be over a million rows in a sheet but you only have to change the cells with the formulas.

  5. #5
    Registered User
    Join Date
    09-02-2020
    Location
    Albany, NY
    MS-Off Ver
    2016
    Posts
    4

    Re: #DIV/0! replace error message with the number 0.

    I did find a pile of VB code that allows me to replace errors with a custom message. This takes away the formula which produced an error and replaces it with text. The problem is that the values in the workbook change on a regular basis and I need to keep the formulas.


    Sub ReplaceErrors()
    'Update 20131216
    Dim Rng As Range
    Dim WorkRng As Range
    Dim ReplaceStr As String
    On Error Resume Next
    xTitleId = "KutoolsforExcel"
    Set WorkRng = Application.Selection
    Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
    ReplaceStr = Application.InputBox("Replace text", xTitleId, Type:=2)
    Set WorkRng = WorkRng.SpecialCells(xlCellTypeFormulas, 16)
    WorkRng.Value = ReplaceStr
    End Sub



    Maybe this code could be reworked to loop through the tabs and reformat cells displaying error messages with the ISERROR() function.

    what do you think?

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: #DIV/0! replace error message with the number 0.

    I was referring to a sample workbook, not a sample code, I can't supply you with a sample because I don't know the layout of the worksheets.

  7. #7
    Registered User
    Join Date
    09-02-2020
    Location
    Albany, NY
    MS-Off Ver
    2016
    Posts
    4

    Re: #DIV/0! replace error message with the number 0.

    The code should work regardless of the exact structure.

    Open excel. Create 130 worksheets in a workbook. On each worksheet generate a few randomly placed formulas that divide by 0.

    The VBA should loop through the worksheets. For each worksheet select the formulas that divide by 0 and modify them to output 0 rather than #DIV/0!

    I just havent used VB to loop through all the cells on all the worksheets in a workbook. I'm surely no VBA expert.

+ 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] Replace error message with text message
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2017, 02:37 AM
  2. [SOLVED] Number format error message
    By luizmachado in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-28-2016, 06:38 PM
  3. Replies: 2
    Last Post: 11-19-2015, 09:20 AM
  4. [SOLVED] replace VBA run-time error message with custom message
    By BEEJAY in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-14-2006, 11:05 AM
  5. [SOLVED] Intercept/replace standard 'cell protected' message with my own message?
    By KR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2006, 10:35 AM
  6. [SOLVED] Error Message When Using Replace
    By Susan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-07-2006, 10:10 AM
  7. Replies: 1
    Last Post: 02-17-2006, 12:10 PM

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