+ Reply to Thread
Results 1 to 4 of 4

Sequential Numbers

  1. #1
    Registered User
    Join Date
    12-31-2005
    Posts
    13

    Sequential Numbers

    Hi

    I have got the code for sequential numbers from McGimpsey's website. Is there a code, that the numbers restart on every change in month.

    Thanks
    SAS

  2. #2
    Bob Phillips
    Guest

    Re: Sequential Numbers

    You could add some code to test whether the date is the 1st and reset to
    one, but is it possible that the workbook is opened more than once in a day?

    BTW, which version are u using, registry or text file?

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "abcdexcel" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hi
    >
    > I have got the code for sequential numbers from McGimpsey's website. Is
    > there a code, that the numbers restart on every change in month.
    >
    > Thanks
    > SAS
    >
    >
    > --
    > abcdexcel
    > ------------------------------------------------------------------------
    > abcdexcel's Profile:

    http://www.excelforum.com/member.php...o&userid=30021
    > View this thread: http://www.excelforum.com/showthread...hreadid=501060
    >




  3. #3
    Registered User
    Join Date
    12-31-2005
    Posts
    13

    Sequential Numbers

    Hi

    Using the text file version.

    There always be more than one invoice in a day.

  4. #4
    Bob Phillips
    Guest

    Re: Sequential Numbers

    Try this

    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
    Dim nDate As String

    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, nDate
    If Month(CDate(nDate)) <> Month(Date) Then
    nSeqNumber = 1&
    Else
    nSeqNumber = nSeqNumber + 1&
    End If
    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, Format(Date, "dd mmm yyyy")
    Close nFileNumber
    NextSeqNumber = nSeqNumber
    Exit Function
    PathError:
    NextSeqNumber = -1&
    End Function


    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "abcdexcel" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hi
    >
    > Using the text file version.
    >
    > There always be more than one invoice in a day.
    >
    >
    > --
    > abcdexcel
    > ------------------------------------------------------------------------
    > abcdexcel's Profile:

    http://www.excelforum.com/member.php...o&userid=30021
    > View this thread: http://www.excelforum.com/showthread...hreadid=501060
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1