I have a form which must be numbered sequentially, incrementing by one everytime the master form is opened. Once a fomr has been filed, the number is to remain constant. How do I have it create the number automatically in the first palce and have it stable once the form has been completed and stored.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Numbered forms (xl97)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Numbered forms (xl97)
- This topic has 8 replies, 3 voices, and was last updated 22 years, 6 months ago.
AuthorTopicWSbobschultzca
AskWoody LoungerOctober 19, 2002 at 3:24 am #378185Viewing 1 reply threadAuthorReplies-
WSAndrewO
AskWoody LoungerOctober 19, 2002 at 7:41 am #625171Intriguing question – but rather depends on what you think of as a form and filing.
For the sake of a reply I assume the form equates to a master workbook used as a template.
I also assume that once you ‘save’ the workbook this equates to ‘filed’. After such a save
you want the next workbook created from the workbooke to be based on the template +1 number?Should be easy with a BeforeSave Routine
The Counter could be stored in a protected cell, or in a Document Property of the original template.I’ll assume it is in a cell with name “MyFormCounter”
The following event Macro should do the trick
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Selection.Locked = False
Range(“MyFormCounter”).Value = Range(“MyFormCounter”).Value + 1
Selection.Locked = True
End Sub -
H. Legare Coleman
AskWoody Plus -
WSAndrewO
AskWoody LoungerOctober 19, 2002 at 6:15 pm #625221Legare
True – the routine I proposed would increment every save – I wasn’t putting too detailed a job into it until I found out more about the problem.
It would be easy enough to only increment on a Saveas (or force one). I also considered that one could use the file NAME as the form counter and increment it via a Saveas as wellI made the assumption that MyFormCounter was the name of the Form number – VBA code didn’t have to do anything with it.
I liked all your questions – the answers will help work through several of the assumptions I made explicitly and implicitly
-
-
WSbobschultzca
AskWoody LoungerOctober 21, 2002 at 10:14 pm #625579Thanks. I tried info. Works well but does not perform as I need. Need master form/template. When it is save the number is incremented, however the new workbook created from the template every time it is saved increments as well. I have set up electronic forms for orders. they are e-mailed and saved by various depatments. Using your programing, every time the new work book is saved the number changes.
Can you help eliminate this problems?
-
-
H. Legare Coleman
AskWoody PlusOctober 19, 2002 at 1:34 pm #625207Before answering, I need the answers to a few questions.
1- Is Andrew’s description of what you want basically corrent? You have a template that you are using to create other workbooks from and you only want to update the sequence number when the workbook created from the template is saved. If the template is used to open a new workbook, and that workbook is closed without saving you do not want to update the number.
2- Is this template shared on a network where multiple users are creating new workbooks from the template.
3- If the workbook is printed before it is saved, what do you want printed as the sequence number. If the template is shared, and you don’t update the number until it is saved, the number could change by the time it is saved.
4- Would you want to force the save immediately after creating a new workbook? If so, where and under what name?
-
WSbobschultzca
AskWoody LoungerOctober 21, 2002 at 10:25 pm #6255981- Template is used to create other workbooks which are distributed to other departments for processing and filing.
2- It is not shared on a network. The new workbook is saved as a file. Yes, I did experience a problem as every time the template or new workbook was saved, the number incremented.
3- The new work book is printed only once for the job file, otherwise everyone in the process loop uses the new workbook file which is e-mailed to them.
4- I tinkered with the VB to force a save of the master/template only so it would be ready for the order entry (new work book).
I do need something to turn the increment off in the new workbook automatically. I do not have any experience with VB but do know how to make minor mods after seeing the lines created when recording a macro.
-
WSAndrewO
AskWoody LoungerOctober 22, 2002 at 12:04 am #625636I’m struggling to understand the problem.
So far I think that :
You have a single template.
You use this template to create a Workbook for departments.
This single created workbook represents a single form which is mailed and saved multiple times, but only printed once?I cannot quite understand if the ‘form’ is in the workbook and always the ‘same’ form or not.
Frankly if there is a single form in a specific workbook the easiest way to achieve uniqueness is to simply name the workbook with the formname as in
Form-12345.xls – where 12345 is the form number
Within the sheet a formula such as
=MID(CELL(“filename”),FIND(“.xls]”,CELL(“filename”),1)-1,5)
would then ‘extract’ the 5 characters just prior to the end of the filename (for numbers of other lengths change the 5 to something else.
However, once again, I’m working on a lot of assumptions due to the fact that I don’t yet understand the problem so will not attempt a detailed robust ‘solution’.
If the above is not close, could you clarify what you think of as a form and describe its “life”. e.g. describe what it is, how it is created , how it is mailed and changed, and when the number is ‘set’.Thanx in advance
-
H. Legare Coleman
AskWoody PlusOctober 22, 2002 at 1:32 am #625663I believe that the code below will do what you want. It keeps the sequence number in a file named Counter.txt which is in the same directory as the template. It also puts the sequence number into cell A1 on Sheet1. This code must be placed in the Workbook BeforeSave event routine.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim strPath As String Dim lSeq As Long Dim iFileNo As Integer If Worksheets("Sheet1").Range("A1").Value "" Then Exit Sub lSeq = 0 iFileNo = FreeFile() On Error Resume Next Open ThisWorkbook.Path & "Counter.txt" For Input As #iFileNo Input #iFileNo, lSeq Close #iFileNo On Error GoTo 0 lSeq = lSeq + 1 Open ThisWorkbook.Path & "Counter.txt" For Output As #iFileNo Write #iFileNo, lSeq Close #iFileNo Worksheets("Sheet1").Range("A1").Value = lSeq End Sub
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Two blank icons
by
CR2
6 hours, 14 minutes ago -
Documents, Pictures, Desktop on OneDrive in Windows 11
by
ThePhoenix
8 hours, 39 minutes ago -
End of 10
by
Alex5723
11 hours, 19 minutes ago -
End Of 10 : Move to Linux
by
Alex5723
11 hours, 48 minutes ago -
Single account cannot access printer’s automatic duplex functionality
by
Bruce
8 hours, 17 minutes ago -
test post
by
gtd12345
17 hours, 20 minutes ago -
Privacy and the Real ID
by
Susan Bradley
7 hours, 28 minutes ago -
MS-DEFCON 2: Deferring that upgrade
by
Susan Bradley
8 hours, 17 minutes ago -
Cant log on to oldergeeks.Com
by
WSJonharnew
21 hours, 42 minutes ago -
Upgrading from Win 10
by
WSjcgc50
9 hours, 6 minutes ago -
USB webcam / microphone missing after KB5050009 update
by
WSlloydkuhnle
16 hours, 47 minutes ago -
TeleMessage, a modified Signal clone used by US government has been hacked
by
Alex5723
1 day, 13 hours ago -
The story of Windows Longhorn
by
Cybertooth
1 day, 1 hour ago -
Red x next to folder on OneDrive iPadOS
by
dmt_3904
1 day, 15 hours ago -
Are manuals extinct?
by
Susan Bradley
2 hours, 47 minutes ago -
Canonical ditching Sudo for Rust Sudo -rs starting with Ubuntu
by
Alex5723
2 days ago -
Network Issue
by
Casey H
1 day, 11 hours ago -
Fedora Linux is now an official WSL distro
by
Alex5723
2 days, 12 hours ago -
May 2025 Office non-Security updates
by
PKCano
2 days, 12 hours ago -
Windows 10 filehistory including onedrive folder
by
Steve Bondy
2 days, 14 hours ago -
pages print on restart (Win 11 23H2)
by
cyraxote
1 day, 15 hours ago -
Windows 11 Insider Preview build 26200.5581 released to DEV
by
joep517
2 days, 17 hours ago -
Windows 11 Insider Preview build 26120.3950 (24H2) released to BETA
by
joep517
2 days, 17 hours ago -
Proton to drop prices after ruling against “Apple tax”
by
Cybertooth
3 days ago -
24H2 Installer – don’t see Option for non destructive install
by
JP
1 day, 16 hours ago -
Asking Again here (New User and Fast change only backups)
by
thymej
3 days, 11 hours ago -
How much I spent on the Mac mini
by
Will Fastie
19 hours, 9 minutes ago -
How to get rid of Copilot in Microsoft 365
by
Lance Whitney
1 day, 14 hours ago -
Spring cleanup — 2025
by
Deanna McElveen
3 days, 17 hours ago -
Setting up Windows 11
by
Susan Bradley
2 days, 12 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.