I am working on a project that needs to have filtering of an excel sheet then pasting in another sheet. Everything works great if there is data in the range. If there is no data I get a 1004 Error.
The range C3:C502 is filtered and all data is hidden, so I do not need the copy and paste, just move on. If there is data, then need the copy/paste.
' Filter Source Data
sheet4.Range("B1").AutoFilter Field:=2, Criteria1:="Direct Embed"
' Apply Filter Direct Embed
sheet4.Select
Range("C3:C502").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
sheet3.Select
Range("D595").PasteSpecial Paste:=xlPasteValues
sheet4.Select
Range("R3:R502").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
sheet3.Select
Range("I595").PasteSpecial Paste:=xlPasteValues
Range("Q3:Q502").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
sheet3.Select
Range("F595").PasteSpecial Paste:=xlPasteValues
The range C3:C502 is filtered and all data is hidden, so I do not need the copy and paste, just move on. If there is data, then need the copy/paste.
' Filter Source Data
sheet4.Range("B1").AutoFilter Field:=2, Criteria1:="Direct Embed"
' Apply Filter Direct Embed
sheet4.Select
Range("C3:C502").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
sheet3.Select
Range("D595").PasteSpecial Paste:=xlPasteValues
sheet4.Select
Range("R3:R502").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
sheet3.Select
Range("I595").PasteSpecial Paste:=xlPasteValues
Range("Q3:Q502").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
sheet3.Select
Range("F595").PasteSpecial Paste:=xlPasteValues