Based on your clarification and suggested code by jeffreybrown. I suggest that you merge the code as follows:
I have kept function to update the serial number out of Workbook_BeforePrint procedure but you are welcome to merge all the code together.
The reason that I suggest using the IncrementSerialNumber() function is because:
- it can increment any serial number provided it is in the following format: sometext-####
- if the number is RAIL-0009 then it will be incremented to RAIL-0010 opposed to RAIL-00010
Do try both our suggestions to see which one fulfils your requirement.
Note: due to time constraint, I haven't been able to test the code changes.
Hope that helps.
Bookmarks