Hello there try replacing you existing code between the Sub and End Sub with the following:
Dim LR As String 'declare variable
With Sheets("Sheet2") 'with the worksheet sheet2
LR = .Range("A6555").End(xlUp).Row 'LR is equal to the last cell in column A that contains a value
If .Range("E1").Value > 0 Then 'if cell E1 is greater than 0 then
With .Range("A1:E" & LR) 'with range A1 through E and the last row
.AutoFilter 'autofilter
.AutoFilter Field:=1, Criteria1:="<>" 'filter out blanks from column A
.AutoFilter Field:=2, Criteria1:="<>" 'filter out blanks from column B
.AutoFilter Field:=3, Criteria1:="<>" 'filter out blanks from column C
.AutoFilter Field:=4, Criteria1:="<>" 'filter out blanks from column D
.AutoFilter Field:=5, Criteria1:="<>" 'filter out blanks from column E
End With
.Range("A2:E" & LR).SpecialCells(xlCellTypeVisible).Select 'select the filtered cells from the range
Selection.Copy 'copy the filtered cells
With Sheets("Sheet1") 'with the worksheet Sheet1
.Range("A" & .Range("A6555").End(xlUp).Row + 1).PasteSpecial 'paste the copied values into the first empty row
End With
End If
With .Range("A1:E" & LR) 'with the range
.AutoFilter 'clear the filter
End With
.Range("A1").Select 'select cell A1
End With
Application.CutCopyMode = False
Anything that appears in green is a comment meant to help you understand the code.
Bookmarks