Counter in Excel template

O

office newbie

Hi,

Before I ask I did spend quite some time searching google groups so I
hope this is an interesting question for someone.

I am creating an template within excel for purchase orders and the user
will enter certain data which will be computed via formula no problem.

MY ISSUE is.....

I the template to hold some sort of counter value which will increment
each and every time a child document is created from it.

First time open counter or P.O. number is 1......second time is 2 etc etc.

This is regardless of whether the child document is saved or anything.

Upon spawning the child increment by one.....

Thanks in advance.
 
L

Leith Ross

Hello office newbie,

This counter will increment every time the template is opened. You ca
also use these same calls elsewhere in the code to increment the counte
if you need to. You can change the names template, opened, and counte
to whatever you like. The counter is stored in the Registry of th
machine it resides on. This insures the count will be accurate, even i
the program crashes.


Code
-------------------
Private Sub Workbook_Open()

Dim Cnt As Long

Cnt = Val(GetSetting("template", "opened", "counter"))
Cnt = Cnt + 1
SaveSetting "template", "opened", "counter", Str(Cnt)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top