Hi all,

Im using a macro to copy and paste visible cells after filtering the data into a new sheet. However, A blank sheet is also getting created as and when there is no data meeting the filtered criteria. I want the sheet to be created only when there is data existing in the master sheet.

Below is the code im using and i don't know where im doing wrong.

Any help is greatly appreciated. Thanks in advance

ActiveSheet.UsedRange.AutoFilter Field:=8, Criteria1:="a"
    
    If Range("A1:A" & LR).SpecialCells(xlCellTypeVisible).Count >= 2 Then
        Range("A1:AZ" & LR).SpecialCells(xlCellTypeVisible).Select
        Selection.Copy
        Set NewSheet = Sheets.Add(After:=Sheets(Worksheets.Count), Count:=1, Type:=xlWorksheet)
        NewSheet.Name = "abc"
        Sheets("abc").Paste Sheets("abc").Range("A1")
        Sheets("Main").Select
        Range("A2:AZ" & LR).SpecialCells(xlCellTypeVisible).Delete
    End If