Monday, December 11, 2017

how to merge excel sheets



Sub MergeFiles()
Path = "C:\Users\dpk\Desktop\Files\"
Filename = Dir(Path & "*.xls*")
  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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.