excelerino
New Member
- Joined
- Nov 2, 2016
- Messages
- 47
Hi all,
I'm trying to get rows with errors automatically deleted whenever a particular sheet is activated. The following code, most of which I got online, give me a subscript out of range error on the bolded line. I saw there was a similar thread earlier today, but I just don't understand the problem
Private Sub Worksheet_Activate()
Dim rng As Range
Dim rngError As Range
Set rng = Worksheets("Sheet7")
On Error Resume Next
Set rngError = rng.Cells.SpecialCells(xlCellTypeFormulas, xlErrors)
On Error GoTo 0
If Not rngError Is Nothing Then
rngError.EntireRow.Delete
End If
End Sub
Thanks in advance!
I'm trying to get rows with errors automatically deleted whenever a particular sheet is activated. The following code, most of which I got online, give me a subscript out of range error on the bolded line. I saw there was a similar thread earlier today, but I just don't understand the problem
Private Sub Worksheet_Activate()
Dim rng As Range
Dim rngError As Range
Set rng = Worksheets("Sheet7")
On Error Resume Next
Set rngError = rng.Cells.SpecialCells(xlCellTypeFormulas, xlErrors)
On Error GoTo 0
If Not rngError Is Nothing Then
rngError.EntireRow.Delete
End If
End Sub
Thanks in advance!