Insert row and copy cells from the currently selected row

G

Guest

New to Excel VBA, but have 10 years programming in Access

I have a row pointer for my worksheet, and a command button on a form that I
want to use to insert a blank row after the currently selected row, and then
copy the data from the first three columns of the currently selected row.
How do I
 
G

Guest

Try following macro:

Sub InsertRow()
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 3)).Copy _
Destination:=Cells(ActualRow + 1, 1)
End Sub


Regards
reklamo
 
R

Ron de Bruin

You can try this Dale

Sub test()
With Cells(ActiveCell.Row, 1)
.Offset(1, 0).EntireRow.Insert
.Offset(1, 0).Resize(1, 3).Value = .Resize(1, 3).Value
End With
End Sub
 
P

pgarcia

Thanks nice, but I have a questions. Can you change the code to start at cell
D34 and also copy the format in row 33?
 

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