Hello and merry Christmas.
I have a template which with a lot of help on from members which saves a spreadsheet with the next sequential number (by adding a number to the relevant square in the template file). This worked great until I made some changes to it! Everything still works as I need it to except it doesn't seem to update the template number therefore every time I run the template it gives the next file the same number. I cannot figure out why this so any help would be gratfully accepted!
Regards
Mick
Sub ReNameFile()
Const wsINV As String = "Imput Sheet"
Dim newFile As String, fName As String
Dim wbook As Workbook
Dim Today As Date
Dim NewVal As Long
Dim Template As String
Dim dt As String, wbNam As String, FileName As String
With ActiveWorkbook
If Range("AA1") = "" Then 'the doublecheck cell
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
Template = "C:\Users\Mick\Documents\Custom Office Templates\New Estimate Template.xltm" 'reopen the template
Workbooks.Open Template
With ActiveWorkbook.Sheets(wsINV) 'update the template's current inv number
.Range("J2").Value = .Range("J2").Value + 1
NewVal = .Range("J2").Value + 1 'remember the new number
ActiveWorkbook.Save 'close the template, save changes
Application.ScreenUpdating = True
Application.EnableEvents = True
End With
End If
With Sheets("Imput Sheet")
Range("J2").Value = NewVal 'put new number into current workbook
Range("AA1") = "Incremented" 'flag the doublecheck cell
If .Range("C3") = "" Then _
.Range("C3").Value = InputBox("Please enter a client name")
If .Range("J4") = "" Then _
.Range("J4").Value = Date
End With
wbNam = Range("A24")
dt = Format(CStr(Now), "dd_mm_yy")
ChDir _
"C:\Users\Mick\Dropbox\SPSL Shared\Estimates 2014\"
ActiveWorkbook.SaveAs FileName:=wbNam & " " & dt, FileFormat:=(52)
End With
End Sub
Bookmarks