Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Generating sequential invoice numbers

I create invoices in Excel and would like to create a macro or some other way
of inserting the next invoice number automatically.

Any ideas anyone?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Generating sequential invoice numbers

See J.E Excel pages
http://www.mcgimpsey.com/excel/udfs/sequentialnums.html

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Rod Ben" <Rod wrote in message ...
I create invoices in Excel and would like to create a macro or some other way
of inserting the next invoice number automatically.

Any ideas anyone?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Generating sequential invoice numbers

Hi Ron

Thanks for this but i cant seem to get it to work. I have copied the code
into a module as suggested on the web site and i can get the macro to run but
get an error message "ambigous name detected : Next SeqNumber".

I am very much in the dark with this code. Anything obvious i am doing wrong?

The code i have used is:

Sub Getinvoicenumber()
Public Function NextSeqNumber(Optional sFileName As String, Optional
nSeqNumber As Long = -1) As Long
Const sDEFAULT_PATH As String = "C:\Documents and Settings\Rod
Bennett\Desktop"
Const sDEFAULT_FNAME As String = "defaultseq.txt"
Dim nFileNumber As Long

nFileNumber = FreeFile
If sFileName = "" Then sFileName = sDEFAULT_FNAME
If InStr(sFileName, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator & sFileName
If nSeqNumber = -1& Then
If Dir(sFileName) < "" Then
Open sFileName For Input As nFileNumber
Input #nFileNumber, nSeqNumber
nSeqNumber = nSeqNumber + 1&
Close nFileNumber
Else
nSeqNumber = 1&
End If
End If
On Error GoTo PathError
Open sFileName For Output As nFileNumber
On Error GoTo 0
Print #nFileNumber, nSeqNumber
Close nFileNumber
NextSeqNumber = nSeqNumber
Exit Function
PathError:
NextSeqNumber = -1&
End Sub
End Sub


Any help greatly appreciated.

Thanks.

Rod

"Ron de Bruin" wrote:

See J.E Excel pages
http://www.mcgimpsey.com/excel/udfs/sequentialnums.html

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Rod Ben" <Rod wrote in message ...
I create invoices in Excel and would like to create a macro or some other way
of inserting the next invoice number automatically.

Any ideas anyone?




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Generating sequential invoice numbers

You copy a function in a macro and that is not correct

Read the page again and copy this function and sub in a normal module
Note I use C:\

Now run the macro a few times to test

Public Function NextSeqNumber(Optional sFileName As String, Optional nSeqNumber As Long = -1) As Long
Const sDEFAULT_PATH As String = "C:\"
Const sDEFAULT_FNAME As String = "defaultseq.txt"
Dim nFileNumber As Long

nFileNumber = FreeFile
If sFileName = "" Then sFileName = sDEFAULT_FNAME
If InStr(sFileName, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator & sFileName
If nSeqNumber = -1& Then
If Dir(sFileName) < "" Then
Open sFileName For Input As nFileNumber
Input #nFileNumber, nSeqNumber
nSeqNumber = nSeqNumber + 1&
Close nFileNumber
Else
nSeqNumber = 1&
End If
End If
On Error GoTo PathError
Open sFileName For Output As nFileNumber
On Error GoTo 0
Print #nFileNumber, nSeqNumber
Close nFileNumber
NextSeqNumber = nSeqNumber
Exit Function
PathError:
NextSeqNumber = -1&
End Function

Public Sub NewClientInvoice()
ThisWorkbook.Sheets(1).Range("B2").Value = NextSeqNumber("Client1.txt")
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Rod Ben" wrote in message ...
Hi Ron

Thanks for this but i cant seem to get it to work. I have copied the code
into a module as suggested on the web site and i can get the macro to run but
get an error message "ambigous name detected : Next SeqNumber".

I am very much in the dark with this code. Anything obvious i am doing wrong?

The code i have used is:

Sub Getinvoicenumber()
Public Function NextSeqNumber(Optional sFileName As String, Optional
nSeqNumber As Long = -1) As Long
Const sDEFAULT_PATH As String = "C:\Documents and Settings\Rod
Bennett\Desktop"
Const sDEFAULT_FNAME As String = "defaultseq.txt"
Dim nFileNumber As Long

nFileNumber = FreeFile
If sFileName = "" Then sFileName = sDEFAULT_FNAME
If InStr(sFileName, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator & sFileName
If nSeqNumber = -1& Then
If Dir(sFileName) < "" Then
Open sFileName For Input As nFileNumber
Input #nFileNumber, nSeqNumber
nSeqNumber = nSeqNumber + 1&
Close nFileNumber
Else
nSeqNumber = 1&
End If
End If
On Error GoTo PathError
Open sFileName For Output As nFileNumber
On Error GoTo 0
Print #nFileNumber, nSeqNumber
Close nFileNumber
NextSeqNumber = nSeqNumber
Exit Function
PathError:
NextSeqNumber = -1&
End Sub
End Sub


Any help greatly appreciated.

Thanks.

Rod

"Ron de Bruin" wrote:

See J.E Excel pages
http://www.mcgimpsey.com/excel/udfs/sequentialnums.html

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Rod Ben" <Rod wrote in message ...
I create invoices in Excel and would like to create a macro or some other way
of inserting the next invoice number automatically.

Any ideas anyone?






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Generating sequential invoice numbers

Hi Ron

Works great!

Many thanks for your time.

Have a good weekend.

Rod

"Ron de Bruin" wrote:

You copy a function in a macro and that is not correct

Read the page again and copy this function and sub in a normal module
Note I use C:\

Now run the macro a few times to test

Public Function NextSeqNumber(Optional sFileName As String, Optional nSeqNumber As Long = -1) As Long
Const sDEFAULT_PATH As String = "C:\"
Const sDEFAULT_FNAME As String = "defaultseq.txt"
Dim nFileNumber As Long

nFileNumber = FreeFile
If sFileName = "" Then sFileName = sDEFAULT_FNAME
If InStr(sFileName, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator & sFileName
If nSeqNumber = -1& Then
If Dir(sFileName) < "" Then
Open sFileName For Input As nFileNumber
Input #nFileNumber, nSeqNumber
nSeqNumber = nSeqNumber + 1&
Close nFileNumber
Else
nSeqNumber = 1&
End If
End If
On Error GoTo PathError
Open sFileName For Output As nFileNumber
On Error GoTo 0
Print #nFileNumber, nSeqNumber
Close nFileNumber
NextSeqNumber = nSeqNumber
Exit Function
PathError:
NextSeqNumber = -1&
End Function

Public Sub NewClientInvoice()
ThisWorkbook.Sheets(1).Range("B2").Value = NextSeqNumber("Client1.txt")
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Rod Ben" wrote in message ...
Hi Ron

Thanks for this but i cant seem to get it to work. I have copied the code
into a module as suggested on the web site and i can get the macro to run but
get an error message "ambigous name detected : Next SeqNumber".

I am very much in the dark with this code. Anything obvious i am doing wrong?

The code i have used is:

Sub Getinvoicenumber()
Public Function NextSeqNumber(Optional sFileName As String, Optional
nSeqNumber As Long = -1) As Long
Const sDEFAULT_PATH As String = "C:\Documents and Settings\Rod
Bennett\Desktop"
Const sDEFAULT_FNAME As String = "defaultseq.txt"
Dim nFileNumber As Long

nFileNumber = FreeFile
If sFileName = "" Then sFileName = sDEFAULT_FNAME
If InStr(sFileName, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator & sFileName
If nSeqNumber = -1& Then
If Dir(sFileName) < "" Then
Open sFileName For Input As nFileNumber
Input #nFileNumber, nSeqNumber
nSeqNumber = nSeqNumber + 1&
Close nFileNumber
Else
nSeqNumber = 1&
End If
End If
On Error GoTo PathError
Open sFileName For Output As nFileNumber
On Error GoTo 0
Print #nFileNumber, nSeqNumber
Close nFileNumber
NextSeqNumber = nSeqNumber
Exit Function
PathError:
NextSeqNumber = -1&
End Sub
End Sub


Any help greatly appreciated.

Thanks.

Rod

"Ron de Bruin" wrote:

See J.E Excel pages
http://www.mcgimpsey.com/excel/udfs/sequentialnums.html

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Rod Ben" <Rod wrote in message ...
I create invoices in Excel and would like to create a macro or some other way
of inserting the next invoice number automatically.

Any ideas anyone?






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
sequential invoice numbering nexor Excel Worksheet Functions 1 June 9th 06 11:11 AM
AUTOMATIC INVOICE NUMBERS Andreas Excel Discussion (Misc queries) 1 March 8th 06 06:59 PM
sequential numbers on invoices Tony Excel Worksheet Functions 2 December 2nd 04 11:05 PM
How do I take two columns of sequential numbers and insert spaces cmrdjr Excel Discussion (Misc queries) 5 December 2nd 04 10:35 PM
automatic order or invoice numbers jwjones Excel Worksheet Functions 1 November 16th 04 06:55 AM


All times are GMT +1. The time now is 07:17 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"