+ Reply to Thread
Results 1 to 3 of 3

Quick and Easy: Copying and Inserting Lines Using VBA

  1. #1
    Registered User
    Join Date
    04-05-2006
    Posts
    9

    Quick and Easy Help Needed: Copying and Inserting Lines Using VBA

    I have an easy one for you guys.... I want to use VBA to make a simple loop that will go down the page in Excel in my current file and duplicate each row, adding it into the row below it. Got any simple VBA code?? I'm too tired to come up with it on my own! THank you!

    Kristen
    Last edited by Kristen; 08-10-2006 at 05:21 PM.

  2. #2
    PCLIVE
    Guest

    Re: Quick and Easy: Copying and Inserting Lines Using VBA

    This code is sloppy and I'm sure there is some overkill in it, but it works.
    The key is, before you run the code, you must click on the cell in column A
    at which row you would like to start this process. If you want to start at
    the top, just click on A1 to select the cell, and then run this code. This
    will find the last row which has data in column A to determine how many
    times the duplication process must repeat. If the last row to be duplicated
    does not have data in column A of that row, you'll need to modify the code
    slightly. Save you're work first.
    HTH,
    Paul


    Sub Macro1()
    i = Range("A65536").End(xlUp).Row
    s = i - ActiveCell.Row + 1
    c = 1

    For r = 1 To i
    ActiveCell.EntireRow.Select
    Selection.Copy
    Rows(Selection.Row & ":" & Selection.Row).Offset(1, 0).Select
    Selection.Insert Shift:=xlDown
    ActiveCell.Offset(1, 0).Select
    If c = s Then End
    c = c + 1
    Next r
    End Sub



    "Kristen" <Kristen.2cce26_1155243612.907@excelforum-nospam.com> wrote in
    message news:Kristen.2cce26_1155243612.907@excelforum-nospam.com...
    >
    > I have an easy one for you guys.... I want to use VBA to make a simple
    > loop that will go down the page in Excel in my current file and
    > duplicate each row, adding it into the row below it. Got any simple
    > VBA code?? I'm too tired to come up with it on my own! THank you!
    >
    > Kristen
    >
    >
    > --
    > Kristen
    > ------------------------------------------------------------------------
    > Kristen's Profile:
    > http://www.excelforum.com/member.php...o&userid=33199
    > View this thread: http://www.excelforum.com/showthread...hreadid=570526
    >




  3. #3
    Registered User
    Join Date
    04-05-2006
    Posts
    9
    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