Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating Sequential Numbering Macro for an Quotation template

I am creating a quotation template for the company I work for. I want
to put in a sequential number every time the document is saved so that
the client has a unique reference number.

I have seen various sequential numbering scripts but cant get them to
run, they always require debugging.

I am a newcomer to running macros so a very simplistic reply would be
appreciated.

Many Thanks
Stewwy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Creating Sequential Numbering Macro for an Quotation template

Put this macro in the workbook module:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
With Sheets("TheSheetName")
.Range("A1") = .Range("A1") + 1
End With
End Sub

This macro increments the number in A1 of a sheet named "TheSheetName" every
time the workbook is saved.
To locate the workbook module, open Excel, open your file, right-click on
the Excel icon found to the left of the word "File" in the menu across the
top of the screen, select View Code, paste the macro into the displayed
module. HTH Otto
"steewwy" wrote in message
ups.com...
I am creating a quotation template for the company I work for. I want
to put in a sequential number every time the document is saved so that
the client has a unique reference number.

I have seen various sequential numbering scripts but cant get them to
run, they always require debugging.

I am a newcomer to running macros so a very simplistic reply would be
appreciated.

Many Thanks
Stewwy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Creating Sequential Numbering Macro for an Quotation template

Stewwy,

Here is one way

Private Const kBaseName As String = "myFile"
Private Const kName As String = "__RefNum__"

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim iPos As Long
On Error GoTo CleanUp
Application.EnableEvents = False

If IsError(Evaluate(kName)) Then
Me.Names.Add Name:=kName, RefersTo:=1
Else
Me.Names.Add Name:=kName, RefersTo:=Evaluate(kName) + 1
End If

Me.SaveAs Filename:=kBaseName & "_ref_" &
Format(Evaluate(Me.Names(kName).RefersTo), "000") & ".xls"
Cancel = False

CleanUp:
Application.EnableEvents = True
End Sub


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

"steewwy" wrote in message
ups.com...
I am creating a quotation template for the company I work for. I want
to put in a sequential number every time the document is saved so that
the client has a unique reference number.

I have seen various sequential numbering scripts but cant get them to
run, they always require debugging.

I am a newcomer to running macros so a very simplistic reply would be
appreciated.

Many Thanks
Stewwy



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
Macro for sequential numbering. Jeff W Excel Discussion (Misc queries) 4 July 12th 08 04:18 PM
Sequential Numbering in a Template Silena K-K Excel Discussion (Misc queries) 2 April 1st 08 11:18 PM
PO with sequential numbering with start / end numbering [email protected] Excel Discussion (Misc queries) 1 April 24th 07 03:38 PM
Creating part # tags using sequential numbering. Andrew M. Excel Discussion (Misc queries) 2 November 28th 06 08:04 PM
Work Order Template Numbering Macro Harald Staff[_4_] Excel Programming 0 August 9th 03 07:39 AM


All times are GMT +1. The time now is 10:30 PM.

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

About Us

"It's about Microsoft Excel"