+ Reply to Thread
Results 1 to 10 of 10

Insert & Sequentially Number Column

Hybrid View

  1. #1
    dee
    Guest

    Re: Insert & Sequentially Number Column

    Thank you Mark. It worked beautifully! So did Ben's, which just goes to
    show that there are many ways to approach this.

    --
    Thanks!

    Dee


    "Mark Driscol" wrote:

    > The following code answers 1). For 2), you can see maybe from the
    > below how to do it?
    >
    > Option Explicit
    >
    > Sub FillColumnA()
    >
    > Dim i As Long
    > Dim lngLastRow As Long
    >
    > ' Insert new column
    > Range("A1").EntireColumn.Insert
    >
    > ' Reset last row of spreadsheet in case any rows
    > ' were previously deleted, cells were cleared, etc.
    > lngLastRow = ActiveSheet.UsedRange.Rows.Count
    >
    > ' Find out last row of spreadsheet
    > lngLastRow = ActiveSheet.Range("A1") _
    > .SpecialCells(xlCellTypeLastCell).Row
    >
    > Range("A1").Value = "Key"
    > For i = 2 To lngLastRow
    > Cells(i, "A").Value = i - 1
    > Next i
    >
    > End Sub
    >
    >
    > Mark
    >
    >
    > dee wrote:
    > > Hi,
    > > I want the sequential numbering to appear in column A, which is newly
    > > inserted. The problem arises when a cell in the neighbouring column (b)
    > > doesn't contain any data, the numbering stops. For example, it will number
    > > 1, 2, 3, etc. down to, say row 10. It stops because in B10 there is an empty
    > > cell. This is a problem, because the data doesn't really stop at b10. There
    > > is data in B11, B12, etc.... just some blank cells here and there, but this
    > > causes Excel to think it has reached the end of the range.
    > >
    > > Basically, I'd love a code snippet that says:
    > > 1. Fill something down an entire column, truly to the end of the data, even
    > > if you encounter a few blank cells in the column to the right (or left
    > > sometimes)
    > > 2. Select down an entire column, truly to the end of the data, even if you
    > > encounter a few blank cells in the column to the right (or left sometimes)
    > >
    > > Hope this is more clear.
    > > Thanks
    > >
    > > --
    > > Thanks!
    > >
    > > Dee
    > >
    > >
    > > "Mark Driscol" wrote:
    > >
    > > > A new column A will not contain any data. When you said "sequentially
    > > > number from A2 to end of data range in column a", did you mean
    > > > 'sequentially number from A2 to end of data range in column b"? This
    > > > is, as long as there are non-blank cells in column B, put data into
    > > > column A? It isn't clear what data in column B have to do with what
    > > > you are asking. Sorry if I am missing something.
    > > >
    > > > Mark
    > > >
    > > >
    > > > dee wrote:
    > > > > Hi,
    > > > > This is relatively simple, but I'm having a bit of trouble with it as I'm
    > > > > not all that familiar with vba.
    > > > >
    > > > > Objective:
    > > > > Insert new column A, title it "Key", sequentially number from A2 to end of
    > > > > data range in column a, i.e. 1, 2, 3, 4, etc.
    > > > >
    > > > > Problem:
    > > > > If column B contains empty cells, the numbering stops. I need it to keep
    > > > > numbering until it truly reaches the end of the data range.
    > > > >
    > > > > Thanks!
    > > > >
    > > > > --
    > > > > Thanks!
    > > > >
    > > > > Dee
    > > >
    > > >

    >
    >


  2. #2
    Robert
    Guest

    Re: Insert & Sequentially Number Column

    Please Rate the Posting since it works and you are happy.
    Robert




+ 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