Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying and inserting lines teo410 Excel Worksheet Functions 6 August 13th 09 05:31 PM
Macro: copying, inserting & autofilling. Steve Simons Excel Discussion (Misc queries) 2 September 19th 06 03:50 PM
Copying row & inserting Chance224 Excel Discussion (Misc queries) 1 September 2nd 06 03:03 AM
Inserting and copying Sean Excel Programming 0 May 2nd 05 10:31 PM
Inserting Lines And Copying Them Troyk Excel Programming 1 May 27th 04 03:19 PM


All times are GMT +1. The time now is 08:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"