Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? -- goeppngr ------------------------------------------------------------------------ goeppngr's Profile: http://www.excelforum.com/member.php...o&userid=30906 View this thread: http://www.excelforum.com/showthread...hreadid=525886 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message ... 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying and inserting lines | Excel Worksheet Functions | |||
Macro: copying, inserting & autofilling. | Excel Discussion (Misc queries) | |||
Copying row & inserting | Excel Discussion (Misc queries) | |||
Inserting and copying | Excel Programming | |||
Inserting Lines And Copying Them | Excel Programming |