LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   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

Hi, I'm sure this works. But can't figure out exactly what you are saying as
some of this seems to be in German. I need a simple step by step explanation
as I'm new to Excel. This was simple for me to do in Lotus. In lotus you name
the macro "0" which means it runs everytime you open the workbook and then
the formula/macro is "get the cell " +1, and then "Save the file" and then
"Quit" and it all works fine. Is there a simple way to do this is Excel with
out writing a novel?

"DM Unseen" wrote:

Use the following code:


'proc for generating invoice numbers form excel. Requires a standard
excel book, not a template, that cannot be set to a shared workbook.
Also it needs a custom documentproperty "template" of type yesno.
'This setup will work with multiple users given the basic xl file is
accesible to all users.
Users should never open the original template as read only.

' procedure voor het automatisch genereren van een invoice nummer
vanuit excel
' Uitgangspunt is een gewoon excel bestand dat niet als template
gebruikt wordt en ook
' niet gedeeltd wordt. Anders kan
' het laatst gebruikte factuurnummer niet teruggeschreven worden naar
de "Template"
' en wordt de factuurtemplate niet beschermd tegen openen door meerdere
gebruikers
' Er moet een documenteigenschap "Template" aangemaakt worden die
aangeeft of het document een
' template is of een factuur.

Private Sub Workbook_Open()
Dim lngInvoiceNr As Long
Dim strName As String
Dim intPos As Integer


' Als bestand een template is, meteen foutmelding en sluiten
If Me.Path = "" Then
MsgBox "factuur geopend als template, gaarne openen als gewoon
bestand", vbCritical, "factuur"
Me.Saved = True
Me.Close
GoTo Exit_here
End If

On Error GoTo Error1

' als dit de template is dat een factuur creeren
If Me.CustomDocumentProperties("Template") Then

'factuurnummer ophogen
With Me.Worksheets(1).Range("M3")
.Value = .Value + 1
lngInvoiceNr = .Value
End With


' template met nieuw factuurnummer opslaan
Application.DisplayAlerts = False
Me.Save
' opgeslagen, dus dit bestand is nou geen template meer
Me.CustomDocumentProperties("Template") = False
Application.DisplayAlerts = True

' bestandsnaam factuurnummer aanmaken
strName = Me.Name
intPos = InStrRev(strName, ".")
If intPos 0 Then strName = Left$(strName, intPos - 1)

' aangeven dat factuur nog niet is opgeslagen
Me.Saved = False

' gebruiker vragen om factuur op te slaan
While Not Me.Saved
Application.Dialogs(xlDialogSaveAs).Show strName &
CStr(lngInvoiceNr)
Wend



End If
Exit_he
' exit code kan hier

Exit Sub
Error1:

MsgBox Err.Description
GoTo Exit_here
End Sub


DM Unseen


 
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 10:41 PM.

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"