Link to home
Start Free TrialLog in
Avatar of Jagwarman
Jagwarman

asked on

VBA Code that will filter and copy but not if there is no data

I need to filer Row 1 Column 'T' to find items that are 'New' When filtered I need to copy the items [but not the header] and paste these onto a new sheet, but if wheh I filter there is no data I do not want to copy anything.

I was trying to use the below code but if there is no data it copies the header

ActiveSheet.Range("$A:$T").AutoFilter Field:=20, Criteria1:="<>"
   
    If ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row > 1 Then
    Range("A2").Select
        Else
   
    End If
   
   
   
    Range("A2").Select
   
    Dim LR As Long
   
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Range("A2:T" & LR).SpecialCells(xlCellTypeVisible).Select
   

    Selection.Copy
    Sheets("Sheet1").Select
    Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Select
    ActiveSheet.Paste

Appreciate some help.
Thank you
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

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
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