Automatic numbering of docs from template

I

Ian

It is my understanding that Excel can automatically number
successive invoices which are opened from an invoice
template (as I recall there is such a template in a
version of Excel that I have used previously). I have
designed a job sheet template and would like to have each
successive jobsheet from this template assigned an
automatically incrementing number which prints out on the
jobsheet. Is this possible?
Thanks
Ian
 
P

Paul B

Ian, this macro by Andrew Poulson will increment the number, in a template,
in cell A1 each time the workbook is opened:

Private Sub Workbook_Open()
' By Andrew Poulsom
'will make a text file called Numbers in C:\Program Files\Microsoft
Office\Office
Dim FName As String
Dim FNo As String
Dim x As Long
FName = Application.Path & Application.PathSeparator & "Number.Txt"
FNo = FreeFile
x = 0
On Error Resume Next
Open FName For Input As #FNo
Input #FNo, x
x = x + 1
' *** Change range reference to suit ***
If Range("A1").Value <> "" Then Exit Sub
Range("A1").Value = x
Close #FNo
FNo = FreeFile
Open FName For Output As #FNo
Write #1, x
Close #FNo
End Sub


--
Paul B
Always backup your data before trying something new
Using Excel 2000 & 97
Please post any response to the newsgroups so others can benefit from it
** remove news from my email address to reply by email **
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top