View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Sequential Numbering in a Template

Dave Peterson posted this a while back.

If the workbook has never been saved, which is the case with a newly created
workbook from the Template, the invoice number will increment.

After saving, the number will not increment when opening that saved workbook.

Private Sub Workbook_Open()
if thisworkbook.path = "" then
'it's never been saved, so increment
Sheet1.Range("H16").Value = Sheet1.Range("H16").Value + 1
end if
End Sub


Gord Dibben MS Excel MVP

On Tue, 1 Apr 2008 11:35:00 -0700, Silena K-K
wrote:

Hi there

I have used the sequential numbering code on the McGimpsey site for a
template I have designed in Excel to insert the next consecutive number each
time the template is opened into a new workbook.

However now what happens is when I save the workbook and reopen it, it
automatically inserts the next sequential number.

How do I restrict the code to inserting a new number into a new workbook
when the template is used but not re-inserting a new number every time the
saved workbook is re-opened.

Thank you, Silena