KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 453
- Office Version
- 2016
- Platform
- Windows
Hi
I use this VBA code to import sheets from another Workbook. There is only one sheet so it is easy. Now I would like to import a sheet with name standing in a sheet “Stamdata” cell A1 from another Workbook that contains many sheets with different names. Some who can help.
Any help will be appreciated
Best regards Klaus W
I use this VBA code to import sheets from another Workbook. There is only one sheet so it is easy. Now I would like to import a sheet with name standing in a sheet “Stamdata” cell A1 from another Workbook that contains many sheets with different names. Some who can help.
Any help will be appreciated
Best regards Klaus W
VBA Code:
Sub Rektangelafrundedehjørner1_Klik()
Dim Path As String
Dim Filename As String
Dim Sheet As Worksheet
Path = Range("a1").Value
Filename = Dir(Path & "*.xlsm")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub