• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to check #DIV/0! value by macro

ThrottleWorks

Excel Ninja
Hi,

I am trying to prepare a macro, which will find all the possible Errors (#DIV/0!, #NA etc.) from the workbook.

The problem is, I do not know how to define the error value (#DIV/0!).

I tried rn.formula & rn.value but this is not working.
I think I have to define error type instead of value but I do not know how to do it.

I am using following code, but this is not working, can anyone please help me in this.

I have also attached the file for reference.

Code:
Sub NACErrorFindMacro()
    Application.ScreenUpdating = False
        Dim MyRng As Range
       
        Dim Lr As Long
        Lr = ActiveSheet.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row
       
        Dim Lc As Long
        Lc = ActiveSheet.Cells.Find("*", SearchOrder:=xlByColumns, _
        LookIn:=xlValues, SearchDirection:=xlPrevious).Column
       
        Set MyRng = Range(Cells(1, 1), Cells(Lr, Lc))
       
            With ActiveSheet
                For Each rn In MyRng
                    If rn.Formula = "#DIV/0!" Then
                        MsgBox "Dhan te dhan"
                        Else
                    End If
                Next rn
            End With
       
           
    Application.ScreenUpdating = True
 

Attachments

  • NacErrorFindMacro.xls
    45.5 KB · Views: 2
Sir, thanks a lot for the help, extreamally sorry for lare reply. (Was facing internent connection problem).

I am trying this, will share the results ASAP.

Have a nice day ahead.
 
@NARAYANK991 Sir, this is working for me. Thanks a lot. Though I have to do some changes/additions to the macro from my side. The core code (provided by you) will remain the same.

Sorry for late reply, thanks for your valuable time.
I will upload the final file once it is complete.
 
Back
Top