Hi Everyone
I have 7 workbooks (single tab) that I need to merge into the master workbook. I have 'put together' a macro that opens the files and moves them to into the master.
As this may be performed repeatedly (the master is split and merged at intervals) is there a way to then delete the files once they have been moved. It just means that when the splitting occurs I get the message 'replace existing file?' which it would be good if I could skip.
The other query was if there was a way to automatically select the seven files (same path as active workbook) and move them without the dialogue box (didn't think you could use an array with workbooks, just sheets?).
I know, there is lots of code on this forum but as I'm a newbie find it too difficult to read and amend. Hence the simplicity of my code (except the bottom bit which I got help with)!!
Would be greatful for any help
![]()
Dim MyWk As String MyWk = "M" & Sheets("Checks").Range("$B$2").Value & " Forecast Outturn.xls" Application.ScreenUpdating = False Call OpenExcelFile Windows("Resources.xls").Activate Sheets("Resources").Select Sheets("Resources").Move After:=Workbooks(MyWk).Sheets("Checks") Windows("Comm.xls").Activate Sheets("Comm").Select Sheets("Comm").Move After:=Workbooks(MyWk).Sheets("Checks") Windows("Strategy.xls").Activate Sheets("Strategy").Select Sheets("Strategy").Move After:=Workbooks(MyWk).Sheets("Checks") Windows("Corp.xls").Activate Sheets("Corp").Select Sheets("Corp").Move After:=Workbooks(MyWk).Sheets("Checks") Windows("BDU.xls").Activate Sheets("BDU").Select Sheets("BDU").Move After:=Workbooks(MyWk).Sheets("Checks") Windows("Hosting.xls").Activate Sheets("Hosting").Select Sheets("Hosting").Move After:=Workbooks(MyWk).Sheets("Checks") Windows("Quality.xls").Activate Sheets("Quality").Select Sheets("Quality").Move After:=Workbooks(MyWk).Sheets("Checks") Range("A1").Select Call Unprotect calculate End Sub Sub OpenExcelFile() Dim vFile As Variant 'Showing Excel Open Dialog Form vFile = Application.GetOpenFilename("Excel Files (*.xls*)," & _ "*.xls*", 1, "Select Excel File", "Open", True) 'If Cancel then exit If TypeName(vFile) = "Boolean" Then Exit Sub End If 'Open selected file For i = 1 To UBound(vFile) Workbooks.Open vFile(i) Next i End Sub
Bookmarks