Good day all.
I'm busy to automate some of our time sheets and overtime reporting. Each employee completes his/her own timesheet in a Excel Spreadsheet. Some of this information is then merged into a monthly summary. At the end of the month the employee is using a button, with a Macro, to print the summary for approval by the manager. Together with this creation of the PDF document, a additional Excel spreadsheet is created with only the totals of the summary sheet. This spreadsheet is then sent to the admin office via email.
The admin person will then receive spreadsheets from all the employees and this is then imported into a master file that is then sent to head office for payroll.
At this stage, the code that I have will import the data one spreadsheet at a time. I would like to modify my code to multi select all the spreadsheets for the month at once and all the information is then imported into the master file.
Probably with something like a array or loop. I'm not sure and not that familiar with VBA yet.
This is the code that I currently have.
Any help will really be appreciated.
I'm busy to automate some of our time sheets and overtime reporting. Each employee completes his/her own timesheet in a Excel Spreadsheet. Some of this information is then merged into a monthly summary. At the end of the month the employee is using a button, with a Macro, to print the summary for approval by the manager. Together with this creation of the PDF document, a additional Excel spreadsheet is created with only the totals of the summary sheet. This spreadsheet is then sent to the admin office via email.
The admin person will then receive spreadsheets from all the employees and this is then imported into a master file that is then sent to head office for payroll.
At this stage, the code that I have will import the data one spreadsheet at a time. I would like to modify my code to multi select all the spreadsheets for the month at once and all the information is then imported into the master file.
Probably with something like a array or loop. I'm not sure and not that familiar with VBA yet.
This is the code that I currently have.
Code:
Sub Import_Monthly_OverTime()
Application.ScreenUpdating = False
Dim FileToOpen As Variant
Dim OpenBook As Workbook, shAllBranch As Worksheet
Dim r As Long
r = Range("A6").End(xlDown).Row + 1
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", Filefilter:="Excel Files (*.xls*),*xls*")
' FileToOpen = Application.GetOpenFilename(Filefilter:="Excel Files (*.xlsx), *.xlsx", Title:="Select Workbook to Import", MultiSelect:=True)
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets(1).Range("A2:L2").Copy
ThisWorkbook.Worksheets("Overtime Sheet").Range("A" & r).PasteSpecial xlPasteValues
OpenBook.Close False
End If
Range("B11").Select
Application.ScreenUpdating = True
End Sub
Any help will really be appreciated.