Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Macro for copying & inserting a row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
goeppngr - 23 Mar 2006 22:52 GMT
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?

Signature

goeppngr

David McRitchie - 24 Mar 2006 17:55 GMT
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

> 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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.