SloanRanger
New Member
- Joined
- Jul 12, 2020
- Messages
- 8
- Office Version
- 2010
- Platform
- Windows
I’m trying to import a specific worksheet that appears in multiple (40) workbooks. I’m not fussed on how the worksheets are ordered in the new work book. The following code works but tried to pull all the worksheets and falls over when it finds hidden worksheets. As said I only want one worksheets copying.
Sub CombineWorkbooks()
Dim FName As String, FPath As String
Dim Sheet As Worksheet
Application.ScreenUpdating = False
FPath = Worksheets("Combine Sheets").Cells(2, 2).Value
FName = Dir(FPath & "\*.xls*")
Do While FName <> ""
Workbooks.Open Filename:=FPath & "\" & FName, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(FName).Close
FName = Dir()
Loop
Application.ScreenUpdating = True
End Sub
Sub CombineWorkbooks()
Dim FName As String, FPath As String
Dim Sheet As Worksheet
Application.ScreenUpdating = False
FPath = Worksheets("Combine Sheets").Cells(2, 2).Value
FName = Dir(FPath & "\*.xls*")
Do While FName <> ""
Workbooks.Open Filename:=FPath & "\" & FName, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(FName).Close
FName = Dir()
Loop
Application.ScreenUpdating = True
End Sub