Hi All. I am trying to copy the sheet containing "EEs" from multiple workbooks in one folder to the active workbook. The code I have runs, but doesn't actually copy the sheets. Any and all help is appreciated!
Code:
Option Explicit
Sub Combine_Dept_Files()
Dim FolderPath, Filename As String
Dim ws As Worksheet
Dim wkb As Workbook
Dim var As Variant
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'Copy Worksheets to Master File
FolderPath = "S:\9Box_Output\Department Reports\"
Filename = Dir(FolderPath & "*.xlsm*")
Do While Filename <> ""
Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
For Each ws In ActiveWorkbook.Sheets
For Each var In Array("EEs*")
If InStr(ws.Name, CStr(var)) Then ws.Copy After:=ThisWorkbook.Sheets(2)
Next var
Next ws
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub