I have Code below to save the current workbook by removing the old month and year before .xls and inserting the new month and year before .xls
I need the code amended so that the file is saved in the current directory, which is C:\My docs\Purchase ledger BR1
Kindly amend code per my requirement
I need the code amended so that the file is saved in the current directory, which is C:\My docs\Purchase ledger BR1
Kindly amend code per my requirement
Code:
Sub Save_file_with_CurrentMonth()
Dim strOldWBName As String
Dim strNewWBName As String
Dim strMonthYear As String
Dim strCurrentDir As String
strOldWBName = ThisWorkbook.Name
' search for the first closing bracket from the right
strOldWBName = Left(strOldWBName, InStrRev(strOldWBName, ")"))
' Get the month and year from cell U1 on Sheet "summary"
strMonthYear = Format(Sheets("summary").Range("U1"), "mmm yyyy")
' Get the current directory path
strCurrentDir = ThisWorkbook.Path
' Replace the date in the current file name with the one from U1
strNewWBName = strOldWBName & " " & strMonthYear & ".xlsm"
' Save the file with the new file name in the current directory
ThisWorkbook.SaveAs Filename:=strCurrentDir & "" & strNewWBName, FileFormat:=xlOpenXMLWorkbookMacroEnabled
End Sub [code]