Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Auto numbering

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Auto numbering

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




"Adam" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
aUTO nUMBERING Udayan New Users to Excel 2 March 12th 09 10:07 AM
Auto-Numbering starguy Excel Worksheet Functions 10 March 27th 06 07:38 AM
help with auto numbering aecon Excel Discussion (Misc queries) 1 October 28th 05 05:52 PM
Auto Numbering jharkins Excel Discussion (Misc queries) 2 July 28th 05 11:46 PM
auto numbering Tricky Nicky Excel Discussion (Misc queries) 2 December 29th 04 05:44 PM


All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"