filter and if blank continue with next piece of code

could an expert provide me with vba code that will enable my macro to continue onto the next piece of code if there is no data after a filter

The code I have is

ActiveCell.AutoFilter Field:=14
        ActiveCell.AutoFilter Field:=15, Criteria1:="<>"
        rngFilterRangePublic.SpecialCells(12).Offset(0, 12).Copy Destination:=Workbooks(wkbk).Sheets("calc").Range("e3")
        rngFilterRangePublic.SpecialCells(12).Offset(0, 16).Copy Destination:=Workbooks(wkbk).Sheets("calc").Range("f3")

which falls over because in some cases there is no data within the filter

Thank you
JagwarmanAsked:
Who is Participating?
 
Rory ArchibaldCommented:
Try this:

    ActiveCell.AutoFilter Field:=14
    ActiveCell.AutoFilter Field:=15, Criteria1:="<>"
    If ActiveSheet.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Count > 1 Then
        With rngFilterRangePublic.SpecialCells(12)
            .Offset(0, 12).Copy Destination:=Workbooks(wkbk).Sheets("calc").Range("e3")
            .Offset(0, 16).Copy Destination:=Workbooks(wkbk).Sheets("calc").Range("f3")
        End With
    End If

Open in new window

0
 
JagwarmanAuthor Commented:
Rory that's perfect many thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.