Serial Numbers

Mike Bellamy

New Member
Joined
Mar 30, 2009
Messages
1
Hi,

How can I add a unique serial number to my excel spreadsheet? I have made a document transmittal template and I want a transmittal number on it that will roll over to a new number every time the template is saved (as an excel xls or xlsx file). I'm hoping there is a built in feature that I can use but haven't been able to find it so far.

Any help would be appreciated.

Thanks,

Mike Bellamy
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
15,488
Office Version
  1. 365
Platform
  1. Windows
Welcome to the board!

Unfortunately no built in feature, also when using "Save as", your original workbook is usually closed without save, so the increment would reset (there are exceptions depending on how you save as, but this would apply to normal use).

Maybe your better option would be to use a "workbook open" event to deal with it.
By adding the code below to the "this workbook" module of your file (please test on a COPY first, not the original), it will increase the serial number by 1 when the file is opened, and save at the same time. The serial number would need to be located in a worksheet cell for this to work.

Code:
Sub workbook_open()
Sheets("Mysheet").Range("A1").Value = Sheets("Mysheet").Range("A1").Value + 1
ActiveWorkbook.Save
End Sub

You will need to change "Mysheet" to the name of the worksheet with the serial number, and "A1" to the containing cell.

Haven't tested the code, it should do what you need, but please, test it on a copy file first.

Hope this helps

Jason
 
Upvote 0

Forum statistics

Threads
1,191,307
Messages
5,985,898
Members
439,986
Latest member
DaveTee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top