321richard
New Member
- Joined
- Aug 21, 2014
- Messages
- 1
I need help writing a macro loop that will copy data from a master file (always open) to all files in a folder (over 80 files in the folder). My current, inefficent method is to explictly state the file names and their location and the master file which is already open. Any help would be much appreciated!!!
The following code shows
The following code shows
Code:
Sub LoopAllFiles()
'OPEN FIRST FILE NAMED "FILE 001.XLSX" AND COPY/PASTE DATA FROM MASTER FILE
Windows("Master File.xlsm").Activate
'file is always open
Range("A71:H87").Select
Selection.Copy
Workbooks.Open filename:="C:\Users\Richard\Desktop\Test Macro Loop\File 001.xlsx"
'need to open all files in the folder without explictly stating their name
Range("A71").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
'OPEN SECOND FILE NAMED "FILE 002.XLSX" AND COPY/PASTE DATA FROM MASTER FILE
Windows("Master File.xlsm").Activate
'file is always open
Range("A71:H87").Select
Selection.Copy
Workbooks.Open filename:="C:\Users\Richard\Desktop\Test Macro Loop\File 002.xlsx"
'need to open all files in the folder without explictly stating their name
Range("A71").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
'OPEN THIRD FILE NAMED "FILE 003.XLSX" AND COPY/PASTE DATA FROM MASTER FILE
Windows("Master File.xlsm").Activate
'file is always open
Range("A71:H87").Select
Selection.Copy
Workbooks.Open filename:="C:\Users\Richard\Desktop\Test Macro Loop\File 003.xlsx"
'need to open all files in the folder without explictly stating their name
Range("A71").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
End Sub