Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How do I create a macro to duplicate the current row?

I want to create a macro that will insert a blank row beneath the current row
and will then copy the contents of the current row to the inserted row.

I can do the operation manually but when I record it as a macro then run the
macro it is not quite right. It works fine if I want to add just one new
row. However, when I need run the macro to add further rows the macro always
returns me to the point (row) where the I ran it for the first time. Does
anyone know what I need to put into the macro, when editing it, to stop this
happening?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default How do I create a macro to duplicate the current row?

Hi

As always post your macro for comments.

Look at this and see if it is what you need:


Sub InsertRowBelow()
ActiveCell.Offset(1, 0).EntireRow.Insert
ActiveCell.EntireRow.Copy Range("A" & ActiveCell.Row + 1)
End Sub

Regards,
Per

"lorenzo" skrev i meddelelsen
...
I want to create a macro that will insert a blank row beneath the current
row
and will then copy the contents of the current row to the inserted row.

I can do the operation manually but when I record it as a macro then run
the
macro it is not quite right. It works fine if I want to add just one new
row. However, when I need run the macro to add further rows the macro
always
returns me to the point (row) where the I ran it for the first time. Does
anyone know what I need to put into the macro, when editing it, to stop
this
happening?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default How do I create a macro to duplicate the current row?

This macro duplicates the row of the active cell:

Sub test()
Cells(ActiveCell.Row + 1, ActiveCell.Column).EntireRow.Insert
Shift:=xlDown
ActiveCell.EntireRow.Copy Destination:=Cells(ActiveCell.Row + 1,
ActiveCell.Column).EntireRow
End Sub

Regards,
Stefi


€žlorenzo€ť ezt Ă*rta:

I want to create a macro that will insert a blank row beneath the current row
and will then copy the contents of the current row to the inserted row.

I can do the operation manually but when I record it as a macro then run the
macro it is not quite right. It works fine if I want to add just one new
row. However, when I need run the macro to add further rows the macro always
returns me to the point (row) where the I ran it for the first time. Does
anyone know what I need to put into the macro, when editing it, to stop this
happening?

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
create a spreadsheet that would insert a current date() when opene Testudo Excel Worksheet Functions 2 May 16th 08 04:10 PM
How do I create a chart that will show 4 weeks of current info? smiles Charts and Charting in Excel 0 August 18th 06 06:07 PM
Create buttom that saves current file in a given filename (Excel) mamealemka Excel Worksheet Functions 3 March 17th 06 12:02 PM
Button/Script to create a new workbook from a current one. downer Excel Worksheet Functions 0 February 17th 06 09:09 PM
How do I create a mailing list with current data in Excel? Amanda Excel Discussion (Misc queries) 1 June 12th 05 06:31 AM


All times are GMT +1. The time now is 03:49 PM.

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"