ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Increment Purchase Order Number (https://www.excelbanter.com/excel-programming/360962-increment-purchase-order-number.html)

Curious

Increment Purchase Order Number
 
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!

Paul B

Increment Purchase Order Number
 
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!




Curious

Increment Purchase Order Number
 
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!






All times are GMT +1. The time now is 08:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com