Met*_*xis 2 excel vba find msgbox
我正在尝试完成一个寻找“ #REF!”的简单宏。由于用户更改行并破坏了基础公式而导致工作表中出现错误。
我已经找到了:
Sheets("Location_Multiple").Select
Range("A1:AL10000").Select
Selection.Find(What:="#REF!", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Run Code Online (Sandbox Code Playgroud)
据我了解,我需要输入If参数为true
MsgBox"Please go back and check...."
Run Code Online (Sandbox Code Playgroud)
我只是不确定如果...应该遵循什么...
任何指针将不胜感激。
试试下面的代码
Sub DisplayError()
On Error Resume Next
Dim rng As Range
Set rng = Sheets("Location_Multiple").Range("A1:AL10000")
Dim rngError As Range
Set rngError = rng.SpecialCells(xlCellTypeFormulas, xlErrors)
If Not rngError Is Nothing Then
For Each cell In rngError
MsgBox "Please go back and check.... " & cell.Address
Next
End If
End Sub
Run Code Online (Sandbox Code Playgroud)