Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default I need a cell to change numbers each time it is opened up.

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default I need a cell to change numbers each time it is opened up.

Only vba code can do this. Something like this will work
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.ActiveSheet
With .Range("B1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "1")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub

"Bcoleman75" wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default I need a cell to change numbers each time it is opened up.

mike thank you but i am very very basic wth this vba codes etc. I don't know
where to begin, do I just copy and past what you have and it should work?

"Mike" wrote:

Only vba code can do this. Something like this will work
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.ActiveSheet
With .Range("B1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "1")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub

"Bcoleman75" wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default I need a cell to change numbers each time it is opened up.

Is your template a true Template(*.XLT)

If not, open a new file and build your invoice layout on a sheet.

Enter this code in Thisworkbook module........to acces that module
right-click on the Excel Icon left of "File" and select "View Code"

Private Sub Workbook_Open()
if thisworkbook.path = "" then
'because the workbook is opened based upon a Template
'it's never been saved, so increment the number.
Sheet1.Range("B1").Value = Sheet1.Range("B1").Value + 1
end if
End Sub

Copy/paste the code into that module.

Alt + q to return to the Excel window.

FileSave AsFile TypeTemplate(*.xlt)


Gord Dibben MS Excel MVP

On Mon, 22 Dec 2008 15:31:01 -0800, Bcoleman75
wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default I need a cell to change numbers each time it is opened up.

I could send you a workbook that is working. Or yes you can just copy and
paste the code into the ThisWorkBook Module.

"Bcoleman75" wrote:

mike thank you but i am very very basic wth this vba codes etc. I don't know
where to begin, do I just copy and past what you have and it should work?

"Mike" wrote:

Only vba code can do this. Something like this will work
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.ActiveSheet
With .Range("B1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "1")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub

"Bcoleman75" wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default I need a cell to change numbers each time it is opened up.

if you have a work book and don't mind sharing that would be great, i've been
working on this for almost 6 wks and there is no software out there to
generate sequnital number system and i just need a code through vb i
guess....thanks for all your help!!!!

"Mike" wrote:

I could send you a workbook that is working. Or yes you can just copy and
paste the code into the ThisWorkBook Module.

"Bcoleman75" wrote:

mike thank you but i am very very basic wth this vba codes etc. I don't know
where to begin, do I just copy and past what you have and it should work?

"Mike" wrote:

Only vba code can do this. Something like this will work
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.ActiveSheet
With .Range("B1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "1")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub

"Bcoleman75" wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default I need a cell to change numbers each time it is opened up.

Where do I send it to

"Bcoleman75" wrote:

if you have a work book and don't mind sharing that would be great, i've been
working on this for almost 6 wks and there is no software out there to
generate sequnital number system and i just need a code through vb i
guess....thanks for all your help!!!!

"Mike" wrote:

I could send you a workbook that is working. Or yes you can just copy and
paste the code into the ThisWorkBook Module.

"Bcoleman75" wrote:

mike thank you but i am very very basic wth this vba codes etc. I don't know
where to begin, do I just copy and past what you have and it should work?

"Mike" wrote:

Only vba code can do this. Something like this will work
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.ActiveSheet
With .Range("B1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "1")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub

"Bcoleman75" wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default I need a cell to change numbers each time it is opened up.

Or you could send you Sheet to

"Bcoleman75" wrote:

if you have a work book and don't mind sharing that would be great, i've been
working on this for almost 6 wks and there is no software out there to
generate sequnital number system and i just need a code through vb i
guess....thanks for all your help!!!!

"Mike" wrote:

I could send you a workbook that is working. Or yes you can just copy and
paste the code into the ThisWorkBook Module.

"Bcoleman75" wrote:

mike thank you but i am very very basic wth this vba codes etc. I don't know
where to begin, do I just copy and past what you have and it should work?

"Mike" wrote:

Only vba code can do this. Something like this will work
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.ActiveSheet
With .Range("B1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "1")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub

"Bcoleman75" wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default I need a cell to change numbers each time it is opened up.

I woud send you the template but its at work and I'm trying to make a dummy
worksheet to just see what i can do then work on it more at my office. if you
have something you can email me that would be nice and I can look it over.
I'm needing a number system for audit purposes.



"Mike" wrote:

Or you could send you Sheet to


"Bcoleman75" wrote:

if you have a work book and don't mind sharing that would be great, i've been
working on this for almost 6 wks and there is no software out there to
generate sequnital number system and i just need a code through vb i
guess....thanks for all your help!!!!

"Mike" wrote:

I could send you a workbook that is working. Or yes you can just copy and
paste the code into the ThisWorkBook Module.

"Bcoleman75" wrote:

mike thank you but i am very very basic wth this vba codes etc. I don't know
where to begin, do I just copy and past what you have and it should work?

"Mike" wrote:

Only vba code can do this. Something like this will work
Private Sub Workbook_Open()
Const sAPPLICATION As String = "Excel"
Const sSECTION As String = "Invoice"
Const sKEY As String = "Invoice_key"
Const nDEFAULT As Long = 1&
Dim nNumber As Long

With ThisWorkbook.ActiveSheet
With .Range("B1")
If IsEmpty(.Value) Then
nNumber = GetSetting(sAPPLICATION, sSECTION, sKEY, nDEFAULT)
.NumberFormat = "@"
.Value = Format(nNumber, "1")
SaveSetting sAPPLICATION, sSECTION, sKEY, nNumber + 1&
End If
End With
End With
End Sub

"Bcoleman75" wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?



  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default I need a cell to change numbers each time it is opened up.

Gord,

Would that code work in a template (.xlt) file as well? I've tried various
methods in the past and had all but given up.
--
Riker1074


"Gord Dibben" wrote:

Is your template a true Template(*.XLT)

If not, open a new file and build your invoice layout on a sheet.

Enter this code in Thisworkbook module........to acces that module
right-click on the Excel Icon left of "File" and select "View Code"

Private Sub Workbook_Open()
if thisworkbook.path = "" then
'because the workbook is opened based upon a Template
'it's never been saved, so increment the number.
Sheet1.Range("B1").Value = Sheet1.Range("B1").Value + 1
end if
End Sub

Copy/paste the code into that module.

Alt + q to return to the Excel window.

FileSave AsFile TypeTemplate(*.xlt)


Gord Dibben MS Excel MVP

On Mon, 22 Dec 2008 15:31:01 -0800, Bcoleman75
wrote:

I need the formula or path to i guess to make a template and each time it is
open it generates a new number, Like a invoice number. For example. in cell
A1 Invoice #
in cell B1 we would have the number 1. then save it and then when you open
the template again the #2 would be in cell B1 automatically? can anyone help?



  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default I need a cell to change numbers each time it is opened up.

Actually the code I provided won't work properly in the Template.

I sort of misread your post<g

The code just prevents the number from updating in the workbook created from
the template when next opened.

You need something like code from John McGimpsey's site to first increment
the number from the template.

http://www.mcgimpsey.com/excel/udfs/sequentialnums.html


Gord

On Fri, 26 Dec 2008 08:53:01 -0800, Riker1074
wrote:

Gord,

Would that code work in a template (.xlt) file as well? I've tried various
methods in the past and had all but given up.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bring focus to same cell every time opened?? Rita Brasher Excel Discussion (Misc queries) 2 July 18th 08 05:57 PM
how do i have a cell number increase by 1 each time file opened DJbase Excel Discussion (Misc queries) 1 May 25th 08 04:17 AM
Saved Changes Gone Next Time Document is Opened Justin Excel Discussion (Misc queries) 2 October 24th 07 09:24 PM
have invoice # roll up, or add 1, each time document is opened Syndee Excel Worksheet Functions 3 March 28th 07 01:04 AM
Make sequential numbers each time sheet is opened Darrell Shuman Excel Worksheet Functions 1 October 19th 05 03:35 AM


All times are GMT +1. The time now is 10:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"