PC Review


Reply
Thread Tools Rate Thread

Auto numbering

 
 
Adam
Guest
Posts: n/a
 
      10th Apr 2009
I have created a template for a sales information sheet. I would like it to
generate a new unique sequential number starting at 100001 every time that
the template is opened. when the file is closed I wold like it to be saved
as a .xls using the unique number plus customer name as the file name.

Can this be done?
 
Reply With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      13th Apr 2009
You will need to track the current used value somewhere in the system. One
way would be to store the value in the template, so that when
it is opened the number is incremented and the template is re-saved back.
After that the close event can be used to save the workbook by building the
filename string comprising the unique key (in A1 in example below) and
customer name (in A2 in example below). Excel 2007 code change the SaveAs
code in open event to suit xl2003 if needed.

Private Sub Workbook_Open()
With Sheets("Sheet1").Range("A1")
.Value = .Value + 1
End With
Application.DisplayAlerts = False
ThisWorkbook.SaveAs _
Filename:="D:\myTemplate.xltm", _
FileFormat:=xlOpenXMLTemplateMacroEnabled
Application.DisplayAlerts = False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sFilename As String
With Sheets("Sheet1")
sFilename = .Range("A1") & Trim(.Range("A2"))
End With
ThisWorkbook.SaveAs "D:\" & sFilename & ".xls"
End Sub


--

Regards,
Nigel
(E-Mail Removed)



"Adam" <(E-Mail Removed)> wrote in message
news:66342B75-8DA9-408C-B023-(E-Mail Removed)...
>I have created a template for a sales information sheet. I would like it
>to
> generate a new unique sequential number starting at 100001 every time that
> the template is opened. when the file is closed I wold like it to be
> saved
> as a .xls using the unique number plus customer name as the file name.
>
> Can this be done?


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto numbering without auto number field firecop1 Microsoft Access Forms 8 4th Jul 2007 02:52 AM
How do I turn off auto numbering or auto hyperlink? =?Utf-8?B?Z29nbw==?= Microsoft Word Document Management 2 26th Oct 2006 10:05 AM
Manual numbering to auto (outline) numbering =?Utf-8?B?RHVrZSBDYXJleQ==?= Microsoft Word Document Management 1 4th May 2006 10:27 AM
Re: P.O. Auto Numbering Trevor Shuttleworth Microsoft Excel Worksheet Functions 0 23rd Mar 2004 06:44 PM
Auto Numbering Mike Banana Microsoft Excel Worksheet Functions 0 22nd Oct 2003 06:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:55 PM.