Home |
Search |
Today's Posts |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lookup formula for purchased items with same invoice number | Excel Discussion (Misc queries) | |||
invoice toolbar for invoice calcuation and assign number | Excel Discussion (Misc queries) | |||
How do I assign an invoice number using the invoice toolbar? | Excel Worksheet Functions | |||
How do I generate a new invoice number when creating new invoice? | Excel Discussion (Misc queries) | |||
How do I change the invoice number assigned in Invoice template... | Excel Discussion (Misc queries) |