+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Valued Forum Contributor
    Join Date
    02-09-2004
    Posts
    99

    inserting sequential numbers into a column

    I have a column of an undefined number of rows where I need to add item numbers from 1 to however many items there are, starting from A9 downwards.

    The last 3 used rows on the sheet contain signatures etc so it should not number the bottom 3 rows.

    pretty sure its fairly simple code but i dont have anything similar from previous files that i can re-use to do this :p

    just needs a simple

    count how many rows are blank from A9 downwards (to say A200)
    for num=1 to count do
    Cell range(A(9+num) = num
    end

    i just dont know the code well enough to write it and make it work :p
    Last edited by neowok; 10-01-2009 at 11:33 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2004
    Posts
    99

    Re: inserting sequential numbers into a column

    ok i managed to do it :D

    Dim lastrow
    lastrow = ActiveSheet.UsedRange.Rows.Count - 11
    For Count = 1 To lastrow
    Cells(7 + Count, 1).Value = Count
    Next Count

  3. #3
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: inserting sequential numbers into a column

    neowok

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  4. #4
    Valued Forum Contributor MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    873

    Re: inserting sequential numbers into a column

    Hi, This will sequentially number column "A" from "A9" to the row three from the Bottom of Column "A" Data.
    Code:
    Sub MG01Oct10
    Dim Last As Integer
    Last = Range("A" & Rows.Count).End(xlUp).row - 3
     With Range("A9")
     .Value = 1
     .AutoFill Destination:=Range("A9:A" & Last), Type:=xlFillSeries
    End With
    End Sub
    Regards Mick

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.2.0