I have the following workbook below
I have the following code to change the month and year based on the month and year in cell D2 on sheet "Recon"
When the mcro is run , the name is changed to
I would like it to have space before the month and year for eg
It would be appreciated if someone could kindly amend my code
Code:
BR1 Purchase_Invoices lissting Aug-2022.xlsm
I have the following code to change the month and year based on the month and year in cell D2 on sheet "Recon"
When the mcro is run , the name is changed to
Code:
BR1 Purchase_Invoices lisstingSep-2022.xlsm
I would like it to have space before the month and year for eg
Code:
BR1 Purchase_Invoices lissting Sep-2022.xlsm
Code:
Sub Save_fileunderMonth()
Dim strNameToSave As String
Dim strFullNm As String
Dim lPos As Long
Dim s As String
strNameToSave = Format(ThisWorkbook.Worksheets("Recon").Range("D2").Value, "mmm-yyyy")
strFullNm = ThisWorkbook.FullName
If InStr(1, strFullNm, strNameToSave, vbTextCompare) = 0 Then
lPos = Len(strFullNm) - Len(strNameToSave) - 4
Mid(strFullNm, lPos, Len(strNameToSave)) = strNameToSave
ThisWorkbook.SaveAs Left(strFullNm, Len(strFullNm) - 5), 52
End If
End Sub
It would be appreciated if someone could kindly amend my code