Hi, So I am trying to pull data from 3 different files into one master file. All the 3 files have the same amount of columns but the rows keep increasing or decreasing.
I am also trying to stack the data one below another. So I pull all the columns from Book1 which includes the headers too, after that headers are not needed so I delete the headers from the other 2 files while doing so..
I have successfully pulled data from Book1, but I have gotten stuck on Book2 hence can't finish the process..
Here is the code so far..
![]()
Sub pullingData() Dim filePath As String Dim SourceWb As Workbook Dim TargetWb As Workbook 'Pulling from book1 Set TargetWb = ActiveWorkbook filePath = TargetWb.Sheets("Master").Range("A1").Value Set SourceWb = Workbooks.Open("C:\Users\xyz\Desktop\Book1.xlsx") For i = 1 To 3 SourceWb.Sheets("Sheet1").Range("A:J").Copy Destination:=TargetWb.Sheets("Master").Range("A1") Next i SourceWb.Close savechanges:=False Range("A" & Rows.Count).End(xlUp).Offset(1).Select 'Pulling from book2 Set TargetWb = ActiveWorkbook filePath = TargetWb.Sheets("Master").Range("A" & Rows.Count).End(xlUp).Offset(1).Value Set SourceWb = Workbooks.Open("C:\Users\xyz\Desktop\Book2.xlsx") Range("1:1").Select Selection.Delete For i = 1 To 3 SourceWb.Sheets("Sheet1").Range("A1" & Selection.End(xlToRight) & Selection.End(xlDown)).Copy Destination:=TargetWb.Sheets("Master").Range("A" & Rows.Count).End(xlUp).Offset(1) Next i SourceWb.Close savechanges:=False End Sub
Bookmarks