Multiple workbook into a Masterwork book

ranjith08

New Member
Joined
Nov 6, 2018
Messages
1
I'm trying to get the information from multiple workbook that follow the same template but with different information on each one into one master workbook but I'm having trouble as the multiple workbook will constantly be changing as more support calls are made, I tried to write the code below but it will only work the workbook as it is not when it's updated in the future. I have attached the sample files hoping someone can help me out with this. Thank you in advance

Code:
[COLOR=#000000][FONT=&quot]Sub LoopThroughDirectory()[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]Dim MyFile As String[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]Dim erow[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]Dim Filepath As String[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]Filepath = "C:\Desktop\CRM\"[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]MyFile = Dir(Filepath)[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]Do While Len(MyFile) > 0[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    If MyFile = "Draft template for CRM.xls*" Then[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    Exit Sub[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    End If[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    [/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    Workbooks.Open (Filepath & MyFile)[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    Range("*:*").Copy[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    ActiveWorkbook.Close[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    [/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(erow, 1), Cells(erow, 4))[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    [/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]    MyFile = Dir[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]Loop[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]End Sub[/FONT][/COLOR]

SAMPLE WORKBOOK DOWNLOAD: https://we.tl/t-YwQhj3pBWw
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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