The code imports all the worksheets on all the Excel files on my folder.
I added a command button as suggested in the website where I got this code. In the long run I would like to apply the data imported to a table I have on the main worksheet, followed by printing the template and then deleting the information so I can start over with the next recent spreadsheet.
For now I only want to know how to import the most recent file to my worksheet.
Private Sub CommandButton1_Click()
Dim directory As String, fileName As String, sheet As Worksheet, total As Integer
directory = "C:\ExcelPract\"
fileName = Dir(directory & "*.xl??")
Do While fileName <> ""
Workbooks.Open (directory & fileName)
For Each sheet In Workbooks(fileName).Worksheets
total = Workbooks("Docket .xls").Worksheets.count
Workbooks(fileName).Worksheets(sheet.Name).Copy _
after:=Workbooks("Docket .xls").Worksheets(total)
Next sheet
Workbooks(fileName).Close
fileName = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub