Celia please...
Posted by Oeloel on August 07, 2000 10:11 PM
Thank you Celia for your valuable help. I now would like to know if you have come up with a different way of doing the procedure below. I got the same situation but it did not work with me, maybe I'm doing something wrong. Many thanks...
Can anyone supply some code that assigns numbers to workbooks in the same way as the MS Excel Invoice Template?
I use the following code(in a normal module) in some workbooks to assign a consecutive number each time a template is opened as a workbook, but I dont really like it.
It seems to me to be a bit indirect (I wrote it when first starting to learn VBA about three months ago and havent got round to working out a better way).
Although it works, would like something more streamlined if possible.
Copy the ref. no. on the active worksheet
Range("A1").Copy
'Open the template
Workbooks.Open filename:="C:Myfile.xlt", Editable:=True
Paste to the template the copied ref. no. + 1
With Range("A1")
.Value = "1"
.PasteSpecial Paste:=xlValues, Operation:=xlAdd
End With
Application.CutCopyMode = False
'Save and close the template
ActiveWorkbook.Close savechanges = True
Celia