shirazsafa
New Member
- Joined
- Nov 29, 2023
- Messages
- 5
- Office Version
- 2003 or older
- Platform
- Windows
Hello
There are several Excel files in one folder.
i ned to Merge a sheet with specific name from multiple workbooks.
For example, sheets(purchase)
with this formula, only the first sheets will be merged -
Please guide me if possible
I thank you in advance for your kindness and love
Thank you
Sub Excellearn()
Dim FileName As String
Dim Path As String
Dim Sheet As Worksheet
Path = "C:\Users\carsys 3\Desktop\Merge sheet\mahmole\"
FileName = Dir("C:\Users\carsys 3\Desktop\Merge sheet\mahmole\" & "*.xlsx")
Do While FileName <> ""
Workbooks.Open FileName:=Path & FileName
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy after:=ThisWorkbook.Sheets(1)
Workbooks(FileName).Close
Next
FileName = Dir()
Loop
End Sub
There are several Excel files in one folder.
i ned to Merge a sheet with specific name from multiple workbooks.
For example, sheets(purchase)
with this formula, only the first sheets will be merged -
Please guide me if possible
I thank you in advance for your kindness and love
Thank you
Sub Excellearn()
Dim FileName As String
Dim Path As String
Dim Sheet As Worksheet
Path = "C:\Users\carsys 3\Desktop\Merge sheet\mahmole\"
FileName = Dir("C:\Users\carsys 3\Desktop\Merge sheet\mahmole\" & "*.xlsx")
Do While FileName <> ""
Workbooks.Open FileName:=Path & FileName
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy after:=ThisWorkbook.Sheets(1)
Workbooks(FileName).Close
Next
FileName = Dir()
Loop
End Sub