![]() |
Open and copy all workbook sheets in a folder to a master file
Hi,
I have a folder with a changing number of status reports in it. Each is standardized and only contains one tab, "Status Report". Each status report has a cell (always B10) categorizing what type it is. I then have a "Infra Crit Master" that originally will have one tab "Summary" also in the folder. What I would like is every time the master file is opened, it will search the folder for workbooks where B10 = True on the "Status Report" tab. It will then make a copy of that worksheet and place this worksheet after "Summary" in "Infra Crit Proj." I'm not proficient at VB and cobbled together this piece of code from other topics: Private Sub Workbook_Open() Dim i As Integer, wb As Workbook With Application.FileSearch .NewSearch .LookIn = "\\lm-intm-01\clientdata$\n0148234\Desktop\Status Report" .SearchSubFolders = False .Filename = "*.xls" .Execute For i = 1 To .FoundFiles.Count Set wb = Workbooks.Open(Filename:=.FoundFiles(i)) If (wb.Worksheets("Status Report").Range("B10") = "TRUE") Then wb.Worksheets("Status Report").copy After:=Workbooks("Infra Crit Proj").Sheets("Summary") End If Next i End With End Sub I understand most of it, but get lost at the actual copying part, not sure of any of the conventions for refering to workbooks, worksheets, etc. Suffice to say it doesn't work. Any help would be greatly appreciated. Thanks! |
All times are GMT +1. The time now is 06:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com