Link to home
Start Free TrialLog in
Avatar of Seamus2626
Seamus2626Flag for Ireland

asked on

Filter and delete

I have the below code to delete selections, if there is no selections there, i get the VBA  error "object required"

How can i ignore this and move on if there is nothing to delete

Thanks
Seamus
Sheets("Sophis").Select
    With ActiveSheet
If .FilterMode Then .ShowAllData
End With

With ActiveSheet
   ActiveSheet.Cells.EntireColumn.Hidden = False

    .AutoFilterMode = False
    .Range("A5").AutoFilter Field:=19, Criteria1:="Matched"
    With .AutoFilter.Range
        On Error Resume Next
        Set rData = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
        On Error GoTo 0
        If Not rData Is Nothing Then
            rData.EntireRow.Delete
        End If
    End With
    .AutoFilterMode = False
End With
ThisWorkbook.Sheets("Sophis").Range("A1").CurrentRegion.Copy _
        Workbooks("NewUnmatched.xls").Sheets("Sophis Aspa Matches").Range("A" & Rows.Count).End(xlUp)(2)

Open in new window

SOLUTION
Avatar of SafetyFish
SafetyFish
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seamus2626

ASKER

Perfect, thanks guys