Home

Visual Basic and Sequential numbers

%3CLINGO-SUB%20id%3D%22lingo-sub-238775%22%20slang%3D%22en-US%22%3EVisual%20Basic%20and%20Sequential%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-238775%22%20slang%3D%22en-US%22%3E%3CP%3EHello%3C%2FP%3E%3CP%3EI%20have%20created%20Visual%20Basic%20code%20to%20create%20an%20auto%20number%2C%20when%20I%20run%20the%20Visual%20basic%20code%2C%20but%20I%20am%20trying%20to%20figure%20out%20how%20to%20run%20it%20automatically%20so%20that%20each%20time%20the%20document%20opens%20it%20will%20create%20a%20new%20unique%20number.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-305942%22%20slang%3D%22en-US%22%3ERe%3A%20Visual%20Basic%20and%20Sequential%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-305942%22%20slang%3D%22en-US%22%3E%3CP%3ESee%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwordmvp.com%2FFAQs%2FMacrosVBA%2FNumberDocs.htm%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECreating%20sequentially%20numbered%20documents%20(such%20as%20invoices)%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-292521%22%20slang%3D%22en-US%22%3ERe%3A%20Visual%20Basic%20and%20Sequential%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-292521%22%20slang%3D%22en-US%22%3E%3CP%3EDavid%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWould%20it%20be%20possible%20to%20borrow%20the%20code%20you%20created%20to%20do%20this%3F%20I%20am%20looking%20for%20a%20way%20that%20every%20time%20my%20excel%20template%20is%20opened%20and%20saved%20it%20is%20given%20a%20unique%20but%20sequential%20number%20from%20the%20previous%20time.%20Similar%20to%20a%20quoting%20system%20or%20a%20transaction%20ID%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-238907%22%20slang%3D%22en-US%22%3ERe%3A%20Visual%20Basic%20and%20Sequential%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-238907%22%20slang%3D%22en-US%22%3EPerfect.%20Thank%20you%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-238821%22%20slang%3D%22en-US%22%3ERe%3A%20Visual%20Basic%20and%20Sequential%20numbers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-238821%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20David%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPress%20Alt%2BF11%20to%20open%20the%20VBA%20editor%2C%20then%20select%20ThisDocument%20code%20module%2C%20and%20copy%20your%20code%20inside%20Document_Open()%20event%20as%20shown%20in%20the%20below%20screenshot.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F44370i946BFB98E5A313EE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Document_Open.png%22%20title%3D%22Document_Open.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E
David Muth
New Contributor

Hello

I have created Visual Basic code to create an auto number, when I run the Visual basic code, but I am trying to figure out how to run it automatically so that each time the document opens it will create a new unique number.

4 Replies
Highlighted

Hi David,

 

Press Alt+F11 to open the VBA editor, then select ThisDocument code module, and copy your code inside Document_Open() event as shown in the below screenshot.

 

Document_Open.png

 

Hope that helps

Perfect. Thank you

David,

 

Would it be possible to borrow the code you created to do this? I am looking for a way that every time my excel template is opened and saved it is given a unique but sequential number from the previous time. Similar to a quoting system or a transaction ID

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies