Sequential numbering and auto save help.

utterly confused

New Member
Joined
Nov 23, 2005
Messages
28
Help please........have had some help from this site already but stuck again.
I am trying to design an invoice template that will auto number each time it is opened, ie; count by one each time and then auto save and close to a particular file. I therefore need the template to stay as a template and the completed invoice to save to a file path.
I have the following codes in at the minute, the saving part of it seems to be working at the moment, that may change!) it's just the numbering that is not working.

Private Sub Workbook_Open()
Sheets("Sheet1").Select
Sheets("Sheet1").Unprotect
Range("H13").Value = Range("IV1").Value + 1
Sheets("Sheet1").Protect
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim fpath As String, fName As String
fpath = "P:\K.B\GB Galvanising orders\"
fName = Sheets("Sheet1").[B13].Value & " - " & _
Sheets("Sheet1").[H14].Text & " - " & _
Sheets("Sheet1").[H13].Value & ".xls"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=fpath & fName
Application.DisplayAlerts = True
End Sub

Please help!! With thanks
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237
I don't see anything changing Range("IV1").Value, just adding one to it and putting it in cell H13. So every time the workbook opens, H13 will be IV1 + 1.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,797
Messages
5,574,366
Members
412,589
Latest member
ArtBOM
Top