• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Increment number from Template

pjpienaar

New Member
Hi there


I would like to know if it is posible to create a worksheet, save it as a template. The when applying the template it creates a number in a specific cell eg. 1 then save that sheet, then reapply the template creating a increment number in the same cell as in above eg. 2 and so on.....


Kindest Regards


Pine Pienaar
 
Pine


Firstly, Welcome to the Chandoo.org Forums


I would add a Button to your worksheet to do what you want

It will increment a cells value and then save the file


The problem with adding it to the files Workbook_BeforeSave event is that if somebody does a Ctrl S as a backup whilst entering data you may get extra incrementing that you didn't want


Such code can be as simple as

[pre]
Code:
Sub Inc_Save()
Cells(1, 1).Value = Cells(1, 1).Value + 1
ActiveWorkbook.Save
End Sub
[/pre]
 
Hui


Sorry to be a pain in the neck again, the code you suggested attached to a button within a workbook would work. I could also have used one workbook with various sheets within the book and then use a referral reference to a cell + 1. However what I want is to setup a worksheet save it as a template. If I need that specific sheet apply the template which would contain let’s say 001, the workbook would then be saved. Next round apply the template and a new work book are created where the cell should now be incremented to 002 and saved as a different workbook as the first one.


Example : Something like a incremented invoice number or quote number where the Template are used to create this invoice or quote each time needed with a new number but the template should remain the same.


Could the code you supplied be incorporated into the template and every time applied increment this number within the template and new worksheet.


Kindest Regards


Pine
 
Old Chippy


First and foremost thank you for the help, I will test it soonest


Kindest Regards


Pine from South Africa
 
Old Chippy


I am in the proses of testing your refered code above, now I would like to post another question.


Is it posible to apply the code to a template (create the template), apply the template to create the first eg. invoice with a invoice number 1 and upon saving the invoice lets say as "Nav Computers", I would like this to be recorded in a record keeping file (XL file)as "Nav Computers" in a column and next to that in the next column number 1 (the invoice number)this all to be done automaticaly with only the name "Nav Computers" as the save input from the user.


Kindest Regards


Pine
 
Back
Top