How do I create a macro to duplicate the current row?

L

lorenzo

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?
 
P

Per Jessen

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
 
S

Stefi

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:
 
D

Don Guillett

Sub insertsamelinerow()
Rows(ActiveCell.Row).Copy
Rows(ActiveCell.Row + 1).Insert
Application.CutCopyMode = False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top