MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Add Row While Copying And Manipulating Data

November 01, 2001 - by Bill Jelen

Ed wrote and asked about a simple macro:

Do you have a macro that can add rows to a spreadsheet (at the bottom or at cell pointer), then copy from the previous row and insert the data in the new row? And, finally delete data in certain cells.

Here is a macro that will insert a row above the cellpointer and copy the contents of the prior row. Let's assume your data extends from A to T, and that you want to delete the contents of the new row's cells H, K, and M

I'll use the keyword ActiveCell to make the macro work in relation to the cell pointer.

Sub AddRowForEd()
    Cells(ActiveCell.Row - 1, 1).Resize(1, 20).Copy _
        Destination:=Cells(ActiveCell.Row, 1)
    Cells(ActiveCell.Row, 8).Clear ' Column H
    Cells(ActiveCell.Row, 11).Clear ' Column K
    Cells(ActiveCell.Row, 13).Clear ' Column M
End Sub

Bill Jelen is the author / co-author of
MrExcel LIVe

A book for people who use Excel 40+ hours per week. Illustrated in full color.