View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jst_se jst_se is offline
external usenet poster
 
Posts: 5
Default Long autonumber beginning with a 0 (zero)

I've found this very nice script for autonumber on a website. Everything
works just fine, but I need som help, please.
The autonumber starts at 41160 and increase with one everytime I open
it. But I want to add a "0" (zero) in the beginning of the autonumber,
instead of 41160 I want the output to be 041160.

The script I use:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim x As Boolean, y As Long
y = Worksheets("Blad1").Range("T2").Value + 1
Set fs = CreateObject("Scripting.FileSystemObject")
x = fs.fileexists("C:\indexlog.txt")
If x Then Kill "C:\indexlog.txt"
Open "C:\indexlog.txt" For Output As #1
Print #1, y
Close #1
End Sub

Private Sub Workbook_Open()
Open "C:\indexlog.txt" For Input As #1
Input #1, x
Close #1
Worksheets("Blad1").Range("T2") = x
End Sub
-

--
//Jst
Reclaim Your Inbox!
http://www.mozilla.org/products/thunderbird/