vba append worksheets into one worbook

jaik22

Board Regular
Joined
Sep 23, 2016
Messages
102
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

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:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,223,970
Messages
6,175,726
Members
452,667
Latest member
vanessavalentino83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top