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

asked on

Error Handler

Hi,

I have the below code.

When there is no closed Items, so the filter returns blank, i want to exit the sub with a message box saying "No closed Items"

Can someone advise where i would slot this in?

Thanks
Seamus








Private Sub CommandButton1_Click()

Dim rData As Range

Application.ScreenUpdating = False

With ActiveSheet
    .AutoFilterMode = False
    .Range("A1").AutoFilter Field:=12, Criteria1:="Closed"
    With .AutoFilter.Range
        On Error Resume Next
        Set rData = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
        On Error GoTo ErrHandler
        If Not rData Is Nothing Then
            rData.EntireRow.copy
        End If
           

    End With
 
End With
 
Call copyOver
 
Application.ScreenUpdating = False





End Sub
ASKER CERTIFIED SOLUTION
Avatar of StephenJR
StephenJR
Flag of United Kingdom of Great Britain and Northern Ireland 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
Avatar of Seamus2626

ASKER

Thanks Stephen!

Seamus