![]() |
In Excell ,formula
I want to generate a new number sequentially everytime I open my excell
document. |
In Excell ,formula
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 "housedoc" wrote: I want to generate a new number sequentially everytime I open my excell document. |
In Excell ,formula
Thank you i will try it.
"kassie" wrote: 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 "housedoc" wrote: I want to generate a new number sequentially everytime I open my excell document. |
All times are GMT +1. The time now is 11:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com