Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Paul,
Thanks for your response. I was able to quickly find the code for what I want from the site you recommended. The problem is, it's not producing the expected result. Here's the code which, when put in a template's ThisWorkbook code module, should produce an incremented sequential number each time the template is used to generate a document: Private Sub Workbook_Open() Const sAPPLICATION As String = "Excel" Const sSECTION As String = "Invoice" Const sKEY As String = "Invoice_key" Const nDEFAULT As Long = 1& Dim nNumber As Long With ThisWorkbook.Sheets("Invoice") With .Range("B1") If IsEmpty(.Value) Then .Value = Date .NumberFormat = "dd mmm yyyy" End If End With With .Range("B2") If IsEmpty(.Value) Then nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT) .NumberFormat = "@" .Value = Format(nNumber, "0000") SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1& End If End With End With End Sub My result: When I choose to "enable macros", nothing happens. I've duplicated the sample worksheet to ensure that the cell references in this macro reflect properly in my worksheet. I've also named the template "Invoice" and renamed sheet1 "Invoice". Hopefully, this is possible for a VB newbie. Thanks again, Lorrie "Paul B" wrote: Curious, have a look here, http://www.mcgimpsey.com/excel/udfs/sequentialnums.html -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2002 & 2003 "Curious" wrote in message ... Hi, I've just looked through several functions to look for a way to increment a number each time a template is opened. It's proving to consume more time than anticipated. Can anyone help? Thanks! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Setup Purchase Order Template to have a automatic number system? | Excel Worksheet Functions | |||
Increment/Increment letter in alphabetical order | Excel Programming | |||
Purchase order | Excel Discussion (Misc queries) | |||
purchase order counter in excel purchase order template | Excel Worksheet Functions | |||
I want a purchase order that includes page number (if to be order. | New Users to Excel |