In Excell ,formula

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to generate a new number sequentially everytime I open my excell
document.
 
Cannot even remember where I got this, but hey, it works like a charm!

Private Sub Workbook_Open()
Const sAPpplicationAs String = "Excel"
Const sSectionAs String = "Quote"
Const sKey As String = "Quotation_key"
Const nDefault As Long = 1&
Dim nQuotNumber As Long

With ThisWorkbook.Sheets("Quotation")
With .Range("Number")
If Not IsEmpty(.Value) Then
nQuotNumber = Range("Number")
SaveSetting sApplication, sSection, sKey, nQuotNumber + 1&
End If
End With
With .Range("Number")
If IsEmpty(.Value) Then
nquotNumber = GetSetting(sApplication, sSection, sKey,
nDefault)
.NumberFormat = "@"
.Value = Format(nquotNumber, "0000")
SaveSetting sAPpplication, sSection, sKey, nquotNumber +
1&
End If
End With
End With
End Sub
 
Thank you i will try it.

kassie said:
Cannot even remember where I got this, but hey, it works like a charm!

Private Sub Workbook_Open()
Const sAPpplicationAs String = "Excel"
Const sSectionAs String = "Quote"
Const sKey As String = "Quotation_key"
Const nDefault As Long = 1&
Dim nQuotNumber As Long

With ThisWorkbook.Sheets("Quotation")
With .Range("Number")
If Not IsEmpty(.Value) Then
nQuotNumber = Range("Number")
SaveSetting sApplication, sSection, sKey, nQuotNumber + 1&
End If
End With
With .Range("Number")
If IsEmpty(.Value) Then
nquotNumber = GetSetting(sApplication, sSection, sKey,
nDefault)
.NumberFormat = "@"
.Value = Format(nquotNumber, "0000")
SaveSetting sAPpplication, sSection, sKey, nquotNumber +
1&
End If
End With
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top