Option Explicit
Sub RefreshSignOffSheets()
'PURPOSE: To loop through all Excel files in a chosen folder
' and update them automatically
Dim wb As Workbook
Dim myPath As String
Dim myFile As String
Dim myExtension As String
Dim FldrPicker As FileDialog
Dim Location As String
Dim newDate As String
'Location folder to save the file to is equal to the path listed on the spreadsheet
Location = Range("B10")
'newDate is the new date to add on to the end of the file names as they save to the new folder
newDate = Range("B13")
'Optimize Macro Speed
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'Retrieve Target Folder Path From User
With Application.FileDialog(msoFileDialogOpen)
.Title = "Select Updated Sign-Off Sheet Folder"
.AllowMultiSelect = False
.Show
myPath = CreateObject("Scripting.FileSystemObject").Getfile(.SelectedItems(1)).ParentFolder.Path & "\"
End With
'In Case of Cancel
NextCode:
myPath = myPath
If myPath = "" Then GoTo ResetSettings
'Target File Extension (must include wildcard "*")
myExtension = "/*.xlsm"
'Target Path with Ending Extention
myFile = Dir(myPath & myExtension)
'Loop through each Excel file in folder
Do While myFile <> ""
'Set variable equal to opened workbook
Set wb = Workbooks.Open(Filename:=myPath & myFile)
'Enter the code here to do whatever you want to do to the opened workbook
'========================================================================
'========================================================================
'Save As and Close Workbook
' ActiveWorkbook.SaveAs Filename:=Location & Left(myFile, Len(myFile) - 15) & newDate & ".xlsm"
ActiveWorkbook.SaveAs Filename:=Location & "\" & Left(myFile, Len(myFile) - 15) & newDate & ".xlsm"
wb.Close
'Get next file name
myFile = Dir
Loop
'Message Box when tasks are completed
MsgBox "ENTER WHAT YOU WANT THE MESSAGE BOX TO SAY HERE"
ResetSettings:
'Reset Macro Optimization Settings
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub