Hi All,
i have a workbook, which saves as pdf and xlsx. it works fine & the code is below
i'm trying to get it to change cell J4 by 1 before it closes. so it changes from number one to number two and so on before it closes.
i have a code that i can get it to work by entering the code in different locations within in the code below. but it save the sheet as the wrong number
I have tried run all Macro's but i get an error when it get to Aftersave.
i can't get the code below in the correct location on the above code to change the number after it saves.
Any help would be good.
Many thanks.
Mattless1
i have a workbook, which saves as pdf and xlsx. it works fine & the code is below
i'm trying to get it to change cell J4 by 1 before it closes. so it changes from number one to number two and so on before it closes.
i have a code that i can get it to work by entering the code in different locations within in the code below. but it save the sheet as the wrong number
I have tried run all Macro's but i get an error when it get to Aftersave.
Code:
Sub SvMe()
Dim wb As Workbook, nbk As Workbook
Dim Path As String, File As String, Filename As String
Path = "C:\Users\Music\Desktop\tunbomne"
Filename = Range("J1")
File = Path & "\" & Filename & " " & Format(Date, "dd-mm-yyyy")
Set wb = ThisWorkbook: Set nbk = Workbooks.Add
wb.ActiveSheet.Copy After:=nbk.Sheets(Sheets.Count)
ActiveSheet.Range("A1:J44").ExportAsFixedFormat Type:=xlTypePDF, Filename:=File, Quality:=xlQualityStandard
nbk.SaveAs Filename:=File
nbk.Close savechanges:=False
i can't get the code below in the correct location on the above code to change the number after it saves.
Code:
Sub Workbook_AfterSave(ByVal Success As Boolean)
Dim s As Range
Set s = Sheets("1").Range("J4")
s = s + 1
End Sub
Any help would be good.
Many thanks.
Mattless1
Last edited: