+ Reply to Thread
Results 1 to 2 of 2

Programmatically assign line numbers

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2013
    Posts
    17

    VBA to generate line #s

    Hi,

    I have a macro that I have had modified to accomplish various tasks. For standardization, I need it to assign line item numbers instead of users doing it. The macro copies a worksheet template multiple times, renames them, and copies various pieces of info to the sheets based on the main worksheet. The user deletes any rows of data they do not want copied. However, I need the line numbers to remain sequential. The attached sheet shows the layout of the main worksheet. Is there a way to do this - remove the line numbers from the main sheet and assign with code? Attached is a view of the main worksheet ("Fill This Out First").

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Programmatically assign line numbers

    Instead of needing VBA to do fancy row renumbering, let the worksheet do the work. Put this formula in C5 and copy down:

    =TEXT(ROW()-4, "0000")


    That should keep the rows numbered when one is deleted randomly in the middle.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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