Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Inserting and Copying Rows.
by Allen Wyatt
(last updated October 1, 2014)
As you are editing worksheets, you may notice that some of your work is done based on work you have done before. For instance, you may have a row of data that you entered in a previous Excel session. In this session, you need to copy that row of data and use it as the basis for your new data, but with a few changes.
In such a situation, it would be nice to have a quick way to enter a blank row after the current row, and copy the data in the current row to the new blank row. There are no intrinsic commands in Excel to do this, but a macro can do it very handily. Consider the following example:
Sub InsertCopyRow1() ActiveCell.EntireRow.Select Selection.Copy Selection.Insert Shift:=xlDown End Sub
In order to use the macro, all you need to do is select a cell in any row. When the macro is run, a duplicate of the current row is inserted just below the row you are in.
The only problem with this solution is that it leaves the Excel interface a bit "messy" (for lack of a better word). When completed, a complete row is still selected, and the new row has the "marching ants" marquee around it.
This problem can be overcome by including commands to collapse the selection and move it to a desired location. Another way is to simply use a different macro that relies on different VBA commands. The following macro will also insert and copy a row, but it leaves the cell that you selected active:
Sub InsertCopyRow2() ActiveCell.Offset(1, 0).EntireRow.Insert ActiveCell.EntireRow.Copy ActiveCell.Offset(1, 0).EntireRow End Sub
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2042) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Inserting and Copying Rows.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
Have you ever copied information from one worksheet to another, only to have the information you paste not look the way you ...Discover More
Is your worksheet, imported from an external source, plagued by non-printing characters that show up like small boxes ...Discover More
Edit a group of workbooks at the same time and you probably will find yourself trying to copy information from one of those ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.