+ Reply to Thread
Results 1 to 4 of 4

numbering macro

  1. #1
    Maasha
    Guest

    numbering macro

    In a database of say 10 columns and 100 rows, how do I record a macro
    that will



    o Insert a new column to the left of column A, then

    o in the new column A, number the rows that contain data in
    column B.



    Note: The numbering should start from 1. Since row 1 has the database
    heading & row 2 has the column headings, the numbering (no. 1) should
    start from row 3 and continue down to the last row that has data in
    column B.


  2. #2
    Bob Phillips
    Guest

    Re: numbering macro


    Columns("A:A").Insert
    For i = 1 to 100
    If Cells(i,"B").Value <> "" Then
    Cells(i,"A").Value = i
    End If
    Next i

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Maasha" <[email protected]> wrote in message
    news:[email protected]...
    > In a database of say 10 columns and 100 rows, how do I record a macro
    > that will
    >
    >
    >
    > o Insert a new column to the left of column A, then
    >
    > o in the new column A, number the rows that contain data in
    > column B.
    >
    >
    >
    > Note: The numbering should start from 1. Since row 1 has the database
    > heading & row 2 has the column headings, the numbering (no. 1) should
    > start from row 3 and continue down to the last row that has data in
    > column B.
    >




  3. #3
    Gary''s Student
    Guest

    RE: numbering macro

    Try:

    Sub Macro1()
    Dim i As Integer
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight
    i = 1
    For j = 3 To 100
    If IsEmpty(Cells(j, 2)) Then
    Else
    Cells(j, 1) = i
    i = i + 1
    End If
    Next
    End Sub
    --
    Gary's Student


    "Maasha" wrote:

    > In a database of say 10 columns and 100 rows, how do I record a macro
    > that will
    >
    >
    >
    > o Insert a new column to the left of column A, then
    >
    > o in the new column A, number the rows that contain data in
    > column B.
    >
    >
    >
    > Note: The numbering should start from 1. Since row 1 has the database
    > heading & row 2 has the column headings, the numbering (no. 1) should
    > start from row 3 and continue down to the last row that has data in
    > column B.
    >
    >


  4. #4
    Maasha
    Guest

    Re: numbering macro

    To Bob Phillips and Gary's Student:
    Many thanks for your help - will try out your suggestions later today.
    M.


+ 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