Excel.Tips.Net ExcelTips (Menu Interface)

Deleting Every X Rows 2

Summary: A macro comes in handy when certain rows need to be removed from a worksheet. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)

When working with data retrieved from another source--such as another user or from an external program--you may have a need to remove certain rows from the data. It is not unusual, for instance, to have the need to remove every third row or every fifth row. The following general steps allow you to delete every X rows without using a macro.

  1. Insert two columns (A and B) on the far left side of the worksheet.
  2. In the new column A, use AutoFill to sequentially number the rows from 1 to the end.
  3. In cell B1 (assuming you have no header row), enter the following formula. (This formula assumes that you want to delete every third row. If you want to delete some other multiple of rows, substitute that number in place of the 3 in the formula.)
  4. =MOD(A1,3)
    
  5. Copy the formula downward to all the other cells in the B column.
  6. Choose Filter from the Data menu, then choose AutoFilter. Small drop-down lists appear at the top of each column in the worksheet.
  7. Using the drop-down list in column B, select the 0. Now, only those rows with a zero in column B appear.
  8. Select all the displayed rows and delete them.
  9. Turn off AutoFilter. (Repeat step 5 to do this.)
  10. Delete columns A and B.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2348) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003

Related Tips:

Organize Your Data! Using the powerful sorting capabilities of Excel can help you get your data into just the order you need. Find out how you can use the full capabilities of sorting to your benefit. Check out ExcelTips: Serious Sorting today!