+ Reply to Thread
Results 1 to 2 of 2

Macro for copying & inserting a row

  1. #1
    Registered User
    Join Date
    01-27-2006
    Posts
    3

    Macro for copying & inserting a row

    I have a large list in which I want the user to select an entire row. I then want them to click on a button which is tied to a Macro that copies and inserts the row on the line below. Can someone help me on this please?

  2. #2
    David McRitchie
    Guest

    Re: Macro for copying & inserting a row

    See Insert a Row using a Macro to maintain formulas
    http://www.mvps.org/dmcritchie/excel/insrtrow.htm

    There are many examples on the page but the primary (first) example
    copies the row above the selection for as many rows as you ask for
    before the selection and REMOVES the constants, retaining the
    formulas. It that is not what you want there are other examples.

    I find your question a bit ambiguous but I think this is what you want,
    it is activated by a double-click. .

    'This will insert an empty row BELOW the active cell and populate
    ' the inserted row with the content of the active cell's row.
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True 'Eliminate Edit status due to doubleclick
    Target.Offset(1).EntireRow.Insert
    Target.EntireRow.Copy Target.Offset(1).EntireRow
    End Sub

    The macro above and below are Event macros and are installed by right
    click on the sheet tab, view code, then place your code there.

    Or possibly amongst these

    'This will insert an empty row BELOW the active cell's row.
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target _
    As Range, Cancel As Boolean)
    Cancel = True 'Eliminate Edit status due to doubleclick
    Target.Offset(1).EntireRow.Insert
    End Sub
    'This will insert an empty row ABOVE the active cell's row.Private Sub Worksheet_BeforeDoubleClick(ByVal Target _ As Range,
    Cancel As Boolean)
    Cancel = True 'Eliminate Edit status due to doubleclick
    Target.Offset.EntireRow.Insert
    End Sub
    ---
    HTH,
    David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
    My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
    Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

    "goeppngr" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I have a large list in which I want the user to select an entire row. I
    > then want them to click on a button which is tied to a Macro that copies
    > and inserts the row on the line below. Can someone help me on this
    > please?
    >
    >
    > --
    > goeppngr
    > ------------------------------------------------------------------------
    > goeppngr's Profile: http://www.excelforum.com/member.php...o&userid=30906
    > View this thread: http://www.excelforum.com/showthread...hreadid=525886
    >




+ 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