XL2000: How to Programmatically Insert Blank Rows in a Worksheet

This article was previously published under Q213318
This article has been archived. It is offered "as is" and will no longer be updated.
SUMMARY
In Microsoft Excel 2000, you can use a Microsoft Visual Basic for Applications macro to programmatically insert a blank row between every row of data on your worksheet. The example in this article contains a sample macro that performs this task.
MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

Sample Macro

To insert a blank row between every row of data, follow these steps:
  1. Start Excel 2000, and then create the following worksheet:
       A1:    222   A2:    333   A3:    444   A4:    555   A5:    666					
  2. Press ALT+F11 to start the Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. In the module sheet, type or paste the following code:
    Sub Insert_Blank_Rows()   'Select last row in worksheet.   Selection.end(xldown).select   Do Until ActiveCell.row = 1      'Insert blank row.      ActiveCell.EntireRow.Insert shift := xldown      'Move up one row.      ActiveCell.Offset(-1,0).Select   LoopEnd Sub					
  5. Press ALT+F11 to return to Excel.
  6. Select cell A1 or any cell that contains data.
  7. Press ALT+F8 to open the Macro dialog box.
  8. In the Macro name list, click Insert_Blank_Rows, and then click Run.The macro returns the following values:
       A1:    222   A2:   A3:    333   A4:   A5:    444   A6:   A7:    555   A8:   A9:    666					
NOTE: If you select a blank cell, Excel places a blank between all 65,000 possible rows on the worksheet. If this happens, press ESC to stop the macro, and then select any cell with data in it and repeat step 7.
XL2000
Properties

Article ID: 213318 - Last Review: 12/05/2015 12:09:48 - Revision: 3.5

Microsoft Excel 2000 Standard Edition

  • kbnosurvey kbarchive kbdtacode kbhowto kbinfo kbprogramming KB213318
Feedback