atuljadhavnetafim
Active Member
- Joined
- Apr 7, 2012
- Messages
- 341
- Office Version
- 365
- Platform
- Windows
Dear Expert
i have 3 file A.xls, B.xls and C.xls in E drive,
now all file have more than 100000 row, i just want to combine all three file in one file.
for this i am using below code but it not working and show me error at Filename = Dir(FolderPath & "*.xls*")
please correct code if any
Thanks
i have 3 file A.xls, B.xls and C.xls in E drive,
now all file have more than 100000 row, i just want to combine all three file in one file.
for this i am using below code but it not working and show me error at Filename = Dir(FolderPath & "*.xls*")
Code:
Sub ConslidateWorkbooks()
'Created by Sumit Bansal from https://trumpexcel.com
Dim FolderPath As String
Dim Filename As String
Dim Sheet As Worksheet
Application.ScreenUpdating = False
FolderPath = Environ("userprofile") & "\E:\"
Filename = Dir(FolderPath & "*.xls*")
Do While Filename <> ""
Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
Application.ScreenUpdating = True
End Sub
please correct code if any
Thanks