+ Reply to Thread
Results 1 to 6 of 6

Sequential Number macro

Hybrid View

rhudgins Sequential Number macro 07-15-2010, 04:55 PM
Leith Ross Re: Sequential Number macro 07-15-2010, 05:06 PM
shg Re: Sequential Number macro 07-15-2010, 05:08 PM
rhudgins Re: Sequential Number macro 07-15-2010, 05:23 PM
Leith Ross Re: Sequential Number macro 07-15-2010, 05:32 PM
rhudgins Re: Sequential Number macro 07-15-2010, 05:36 PM
  1. #1
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Sequential Number macro

    A59 is #1, A86 is #2 and A113 is #3. Can someone help me write a macro to automatically insert these #'s in sequential order. A59 will always be #1 and more #'s will be added over time.

    Any help would be great!
    Attached Files Attached Files
    Last edited by rhudgins; 07-15-2010 at 05:36 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Sequential Number macro

    Hello rhudgins,

    Are you sure you want a macro to do this? You easily use a formula to increment the number.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Sequential Number macro

    Select A58:A84 and drag down as far as desired.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Sequential Number macro

    A macro would be great because the data is going to be deleted and inserted frequently.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Sequential Number macro

    Hello rhudgins,

    Here is the macro ...
    Sub AddSequenceNumbers()
    
      Dim N As Long
      Dim Rng As Range
      Dim RngEnd As Range
      
        N = 1
        Set Rng = Range("A1")
        Set RngEnd = Cells(Rows.Count, Rng.Column).End(xlUp)
        Set Rng = Range(Rng, RngEnd)
        
          For Each Cell In Rng
            If Cell = "Trade #" Then Cell.Offset(1, 0) = N: N = N + 1
          Next Cell
          
    End Sub

  6. #6
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Sequential Number macro

    perfect!! Thank you!

+ 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