I've seen answers to this questions that are variations of what I'm looking for but when I attempt to modify the code to my situation, I keep getting error messages.
I have two workbooks, a Master "Template" and a monthly report called "YTDJune2015". Each has 15 sheets which are the same for both, and I want to copy data from the monthly report into the Template which has formulas to calculate additional data for each of the 15 unique Sheets. I want to use the "Open" dialog box as a way to choose the source workbook because the report is updated monthly. I keep getting an error "Object Required" after I select the source document in the open dialog box, and can't figure out how to allow it to open the source workbook. The range part of the code may be incorrect as well but I haven't been able to get past the opening of the source document so I can't check it. I want it to loop through every sheet in the source workbook and copy the same range, then paste into the destination workbook. So far the code I have is:
Sub UpdateWorkbook()
Dim wbSource As Workbook, wbDest As Workbook
Dim ws As Worksheet, rng As Range
Application.ScreenUpdating = False
Set wbSource = Application.GetOpenFilename(FileFilter:="Excel Filter (*.xlsx), *.Xlsx", Title:="Open File(s)", MultiSelect:=False)
Set wbDest = Workbooks.Open("Template.xlsm")
For Each ws In wbSource.Sheets
For Each rng In ws.Range("C8:AB117").Areas
wbDest.Sheets(ws.Name).Range(rng.Address).Value = rng.Value
Next rng
Next ws
wbSource.Close SaveChanges:=False
Application.ScreenUpdating = True
End Sub
Displays the standard Open dialog box and gets a file name from the user without actually opening any files.
I'd suggest FSO. – findwindowDim sFile as String
|sFile = Application.GetOpenFilename ...
|Set wbSource = Workbooks.Open(sFile)
pipes represent line breaks in code. And what is different about the filepaths for each user? It is just the drive letter? – Scott Holtzman