LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default How do you add 1 to an invoice number in Excel. Formula for th

I tried this and get and "invalid outside procedure" with the "UniqueID"
hi-lited. what am I doing wrong. Susan

"Bob Phillips" wrote:

You could define a name in your workbook, and use this value when the file
opens.

Add this code to theThisWorkbook code module within the workbook and it will
automatically increment the Name UniqueId every time the workbook is opened.

You can then acess that name in your code by plugging this into the existing
code that needs the Id.

Evaluate(ThisWorkbook).Names("__UniqueId").RefersT o)

'-------------------------------------------------------------
Private Sub Workbook_Open()
'-------------------------------------------------------------
GetId
End Sub

'-------------------------------------------------------------
Private Sub GetId()
'-------------------------------------------------------------
Dim myId As Long

myId = 1 ' in case it doesn't already exist
On Error Resume Next
myId = Evaluate(ThisWorkbook.Names("__UniqueId").RefersTo ) + 1
ThisWorkbook.Names.Add Name:="__UniqueId", RefersTo:="=" & myId

End Sub
'-------------------------------------------------------------

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

"Susan" wrote in message
...
I'm trying to set up my own invoices. What I can't seem to do is create a
cell for my invoice number, that every time I open the file it adds 1

(0ne)
to the invoice number. Does anyone have a macro - formula for doing this?
Thank you




 
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
Lookup formula for purchased items with same invoice number Johnds Excel Discussion (Misc queries) 5 May 9th 07 01:40 PM
invoice toolbar for invoice calcuation and assign number KarenY Excel Discussion (Misc queries) 15 March 16th 07 12:02 PM
How do I assign an invoice number using the invoice toolbar? Sharon Excel Worksheet Functions 1 December 23rd 06 09:32 AM
How do I generate a new invoice number when creating new invoice? KiddieWonderland Excel Discussion (Misc queries) 1 March 15th 06 03:19 AM
How do I change the invoice number assigned in Invoice template... akress Excel Discussion (Misc queries) 1 February 28th 05 06:36 PM


All times are GMT +1. The time now is 06:32 AM.

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

About Us

"It's about Microsoft Excel"