I want to write a macro which will enable the user, who has selected any row, to insert a new row above the selected row, and copy the data in columns A and B from the row above the inserted row.
I have:
This copies the entire previous row. How do I copy only columns A and B, for example? I am sure there is an utterly simple answer but I keep getting syntax or runtime errors with whatever I try.Code:ActiveCell.EntireRow.Select Selection.EntireRow.Insert Selection.Offset(-1).Select Selection.Copy Selection.Offset(1).Select ActiveSheet.Paste
Thank you.
Perhaps like so, which will insert a row above whichever cell is active:
Code:With ActiveCell .Offset(-1).EntireRow.Insert Cells(.Row, 1).Resize(, 2).Copy Cells(.Row - 1, 1) End With
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks