Reputation: 616
I'm able to run this code without any error, however is giving a slightly different objective.
It'll be added below the Do Events section according to the code in the link below.
Loop through all excel file in given folder
Objective of code:
Current Situation:
E.g File exist in
C:\Users\Tyler\Desktop\Test
New file with date will be saved in
C:\Users\Tyler\Desktop
Codes
Dim CellDate As String, fName As String
fName = Left(ActiveWorkbook.Name, (InStrRev(ActiveWorkbook.Name, ".", -1, vbTextCompare) - 1))
CellDate = ThisWorkbook.Worksheets("Sheet1").Range("H2")
CellDate = Format(Date, "YYYYMMDD")
ActiveWorkbook.SaveAs fName & "-" & CellDate, FileFormat:=xlOpenXMLWorkbookMacroEnabled
Appreciate the help (:
Upvotes: 0
Views: 86
Reputation: 84465
Have you tried
ActiveWorkbook.SaveAs myPath & fName & "-" & CellDate, FileFormat:=xlOpenXMLWorkbookMacroEnabled
If your code for folder selection is as per the link then its value will be stored in myPath.
Assuming "C:\Users\Tyler\Desktop\Test" was the folder selected.
Note:
Associated code from link....
'Retrieve Target Folder Path From User
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
myPath = .SelectedItems(1) & "\"
End With
Upvotes: 1