Hi All,
I am trying to copy worksheets from files that are all in the same folder (current folder of the "main" file). This folder name changes, so I don't want to hardcode the file path into the code. I have the below code, but it isn't doing anything. There are no debug/errors, it just completes without updating. I've used this code in the path with no issue. Any and all help is appreciated,
I am trying to copy worksheets from files that are all in the same folder (current folder of the "main" file). This folder name changes, so I don't want to hardcode the file path into the code. I have the below code, but it isn't doing anything. There are no debug/errors, it just completes without updating. I've used this code in the path with no issue. Any and all help is appreciated,
Code:
Option Explicit
Sub Consolidate_WBS()
Dim FolderPath, Filename, FolderName As String
Dim ws, sht, trg, wsht, wks, wrks As Worksheet
Dim wrk, wb As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'Copy worksheets to file
FolderPath = Application.ActiveWorkbook.Path
Filename = Dir(FolderPath & "*.xlsx*")
Do While Filename <> ""
Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
For Each ws In ActiveWorkbook.Sheets
ws.Copy After:=ThisWorkbook.Sheets("Detail")
Next ws
Workbooks(Filename).Close
Filename = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub