Results 1 to 11 of 11

Fill sequential number down empty column, save last number, use as first number next time

Threaded View

shepardrf Fill sequential number down... 10-25-2013, 03:05 PM
hectop Re: Fill sequential number... 10-25-2013, 03:38 PM
shepardrf Re: Fill sequential number... 10-26-2013, 10:23 PM
hectop Re: Fill sequential number... 10-27-2013, 02:00 PM
shepardrf Re: Fill sequential number... 10-27-2013, 06:32 PM
hectop Re: Fill sequential number... 10-27-2013, 08:36 PM
shepardrf Re: Fill sequential number... 10-29-2013, 10:59 AM
hectop Re: Fill sequential number... 10-29-2013, 09:48 PM
shepardrf Re: Fill sequential number... 10-30-2013, 09:15 AM
hectop Re: Fill sequential number... 10-30-2013, 06:35 PM
shepardrf Re: Fill sequential number... 10-30-2013, 07:29 PM
  1. #1
    Registered User
    Join Date
    10-16-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Office 365
    Posts
    17

    Fill sequential number down empty column, save last number, use as first number next time

    New poster to forum. Hope I am doing this correctly. Thanks for all the help you have been in the past without me posting!

    I have a macro, inserted below, attributed to Harald Staff, that reads a text file for the last incremental number, and then fills B5 with the next number, and updates the text file. Works great, but it currently only fills one cell (B5).

    I need it to fill all the empty rows down column B, and then save that last number. The number of rows that need to be numbered changes from use to use. There is always data in column A and column C. Column B is always empty before the macro runs.

    I am afraid it is beyond me to get it to determine the last row (last data in Column A or C) and to get it to fill B5 down to the last row with an incremental number, starting at the saved number plus one, and then store the last number in the text file for future reference.

    Thanks in advance for any help you can provide.

    Bob

    Here is the current code:

    Sub Lead_Number()
    'by Harald Staff
    Dim ThisInvoice As Long
    Dim ReadText As String
    Dim StoreFile As String
    
    StoreFile = "C:\Data\LeadNumberMaster.txt"
    'replace with another path,
    'network folder if multi-user
    
    'read previous number:
    If Dir(StoreFile) = "" Then 'not found
        ThisInvoice = 1
    Else
        Open StoreFile For _
            Input Access Read As #1
        While Not EOF(1)
            Line Input #1, ReadText
            ThisInvoice = Val(ReadText)
        Wend
        Close #1
    End If
    ThisInvoice = ThisInvoice + 1
    
    'Store this number:
    Open StoreFile For _
        Output Access Write As #1
    Print #1, ThisInvoice
    Close #1
    With Range("B5")   ' change to suit
    .Value = ThisInvoice
    End With
    End Sub
    You almost have the code tags correct the last 1 needs to be [/code
    Last edited by FDibbins; 10-25-2013 at 03:44 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need macro that will update a sequential number field each time I print a form
    By eradline in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2012, 05:55 PM
  2. Lookup largest number in a column treating negative number as postive number
    By xWiZardx in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2010, 08:09 AM
  3. How do I generate a sequential serial number every time I tab to a new line?
    By asbo604 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-28-2009, 05:17 AM
  4. Replies: 7
    Last Post: 12-18-2008, 07:34 PM
  5. Replies: 2
    Last Post: 08-06-2008, 05:18 AM

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