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.
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