Advertisement
baykaone

Replace Errors

Nov 10th, 2020 (edited)
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub ReplaceErrorsInSetRange()
  2.     Dim Rng As Range, selRng As Range, bError As Byte, myCell As Variant
  3.     'below you set own searched range
  4.    Set Rng = Range("A1:Z1000")
  5.     '=============================
  6.    For Each myCell In Rng
  7.         If myCell.Value <> "" Then
  8.             If selRng Is Nothing Then
  9.                 Set selRng = myCell
  10.             Else
  11.                 Set selRng = Union(selRng, myCell)
  12.             End If
  13.         End If
  14.     Next
  15.     If Not selRng Is Nothing Then selRng.Select
  16.     For Each selRng In Selection.Cells
  17.         For bError = 3 To 3 Step 1
  18.             With selRng
  19.                 If .Errors(bError).Value Then .Errors(bError).Ignore = True
  20.             End With
  21.         Next
  22.     Next
  23. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement