Hi all,
I want to copy filtered data from one workbook and paste the data into another. The column that should be filtered is column Z, and it should be filtered on the value "Yes". Once the data is filtered, I want to copy the data in columns A - T (U-Z are formulas that I don't want to copy) into another workbook. Below is the code I am currently using:
However, I get the following error:
Any idea how to solve this?
Best,
I want to copy filtered data from one workbook and paste the data into another. The column that should be filtered is column Z, and it should be filtered on the value "Yes". Once the data is filtered, I want to copy the data in columns A - T (U-Z are formulas that I don't want to copy) into another workbook. Below is the code I am currently using:
VBA Code:
Sub Paste_Data()
Application.DisplayAlerts = False
Application.EnableEvents = False
Workbooks.Open "[File Location]"
Workbooks("[File Name].xlsx").Sheets("Sheet1").Range("A1:Z1").AutoFilter
Workbooks("[File Name].xlsx").Sheets("Sheet1").Range("A1:Z100000").AutoFilter Field:=26, Criterial:="Yes"
Workbooks("[File Name].xlsx").Sheets("Sheet1").Range("A1:T100000").SpecialCells(xlCellTypeVisible).Copy
ThisWorkbook.Sheets("[Tab Name]").Range("A2").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Workbooks("[File Name].xlsx").Close SaveChanges:=True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
However, I get the following error:
Any idea how to solve this?
Best,