Excel.Tips.Net Welcome toExcel.Tips.Net

Helpful Links

Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment

Tips.Net Store

ExcelTips FAQ
ExcelTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

Newest Tips

Converting to Octal

Filtering Columns for Unique Values

Printing Multiple Worksheets on a Single Page

Changing the Default Font

Creating a Drawing Object

Determining a Value of a Cell

Understanding Macros

 

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

Step Up and Take Control! Subscribers to ExcelTips know just how valuable a resource it is. ExcelTips Premium provides twice the number of exceptional, easy-to-understand tips every week in an ad-free newsletter, as well as substantial discounts on ExcelTips archives and e-books.
 
Check out ExcelTips Premium today!