I need to copy a master project list from one workbook to all of the other workbooks in a specific folder. I have tried - see my macro below. While the macro does not give me an
Try this one:
Sub Macro1()
Dim file As String
Dim myPath As String
Dim wb As Workbook
Dim rng As Range
Dim wbMaster As Workbook
'if master workbook already opened
Set wbMaster = Workbooks("Master Project list (2).xlsx")
'if master workbook is not opened
'Set wbMaster = Workbooks.Open("C:\Users\New folder\Master Project list (2).xlsx")
Set rng = wbMaster.Sheets("Master Project list").Range("A1:D34")
myPath = "C:\Users\New folder\" ' note there is a back slash in the end
file = Dir(myPath & "*.xls*")
While (file <> "")
Set wb = Workbooks.Open(myPath & file)
rng.Copy
With wb.Worksheets("Master Project list").Range("A1")
.PasteSpecial xlPasteColumnWidths
.PasteSpecial xlPasteAll
End With
wb.Close SaveChanges:=True
Set wb = Nothing
file = Dir
Wend
Application.CutCopyMode = False
End Sub