I am trying to append data into one workbook based on conditions.
here are the conditions that I am trying to add.
1. If workbook name contains ts.xlsm filter column 5 Criteria1:="<10001" and copy and paste into master workbook
2. If workbook name contains sa.xlsm filter column 5 Criteria1:=">10001" and copy and paste into master workbook
I've got something like this, but can't figure out how to paste into the master workbook, and ways to add the second condition into the code.
Is there any a good way to solve this?
Thank you
here are the conditions that I am trying to add.
1. If workbook name contains ts.xlsm filter column 5 Criteria1:="<10001" and copy and paste into master workbook
2. If workbook name contains sa.xlsm filter column 5 Criteria1:=">10001" and copy and paste into master workbook
Code:
Sub MacroRun()
Dim file
Dim path As String
Application.ScreenUpdating = False
path = "C:\Users\Desktop\Test\New folder\"
file = Dir(path & "*ts.xlsx")
Do While file <> ""
Workbooks.Open Filename:=path & file
Selection.AutoFilter
ActiveSheet.Range("$A$1:$L$1").AutoFilter Field:=5, Criteria1:="<10001" _
, Operator:=xlAnd
ActiveWorkbook.Close
file = Dir()
Loop
MsgBox "Compeleted"
End Sub
I've got something like this, but can't figure out how to paste into the master workbook, and ways to add the second condition into the code.
Is there any a good way to solve this?
Thank you
Last edited: