Hello! I've got a little code problem, and seeing as I'm not completely familiar with VBA, I need a little help. I'm trying to get a proposal template to autonumber. Found a great code that I thought would get the job done, but I'm not sure if I've done it right.
This code was taken from http://www.mcgimpsey.com/excel/udfs/sequentialnums.html. I took out the date portion, as I don't need that, but the numbering part is not working when I open a new workbook using my template. My template name is Practice Proposal Template.xltm. The worksheet I'm running this on is called Cover Sheets. Any help would be appreciated.
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Cover Sheets"
Const sKEY As String = "Cover Sheets_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long
With .Range("B2")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End Sub
Thank you for the help!!
Jennifer
This code was taken from http://www.mcgimpsey.com/excel/udfs/sequentialnums.html. I took out the date portion, as I don't need that, but the numbering part is not working when I open a new workbook using my template. My template name is Practice Proposal Template.xltm. The worksheet I'm running this on is called Cover Sheets. Any help would be appreciated.
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Cover Sheets"
Const sKEY As String = "Cover Sheets_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long
With .Range("B2")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "0000")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End Sub
Thank you for the help!!
Jennifer