How to Delete Every Other Row in Excel
How to Delete Every Other Row in Excel
This wikiHow will teach you how to use a macro with Microsoft Visual Basic for Applications to delete every other row in an Excel worksheet.
Steps

Using a Formula and Filter

Open a project in Excel. This method works for the current Excel as well as previous versions. You can either click on an Excel file to open it or create a new one.

Select a column after your data. If you have data in cells A1-A9 and B1-B-9, you'll want to use column C to insert your formula.

Enter the following code into cell C1: "=ISEVEN(ROW())." As you type that into the function bar, you'll see suggestions pop-up for the formula; selecting one of these ensures you're spelling it correctly. You'll see that every even row is labeled "True" and every false row comes back "False" so you can quickly determine which rows to delete.

Drag and drop the formula from C1 to C9. You want to make sure your entire range is covered.

Click the Data tab. You'll see this at the top of your worksheet.

Click Filter. You'll see this with an icon of a filter in the Sort & Filter grouping.

Click Android 7 Expand More next to the column header in column C. A filter menu will drop-down.

Click to uncheck "True" or "False." Hiding one of these will display every other column of information. You'll want to display the rows that you're going to delete. Click Ok to continue.

Select all the visible data. You can drag and drop around the range of data or press Ctrl + A (Windows) or Cmd + A (Mac).

Right-click the selected data and select Delete Row. All that data will be deleted, and the other rows are hidden.

Unhide your data. Go back to the Data tab and click Filter and your filters will be removed, displaying your original data. Delete column C to remove that data and label.

Using Visual Basic for Applications

Open a project in Excel. This method works for the current MS Excel to Excel 2007 and you can use a saved project or create a new one and enter data into some cells.

Click Tools. For certain older versions of Excel, you'll access the "Developer" tab instead.

Click Visual Basic Editor. You should see this as the leftmost icon in the menu.

Right-click a sheet. In the vertical menu on the left side of the window, you'll see a list of your workbook's sheets. Right-click on any of these to get another drop-down menu.

Hover your cursor over Insert and click Module. When you hover over Insert, a menu will pop-out to the right of the menu. Clicking on Module will create a space for you to enter a VBA code and run it.

Enter the following in your VBA window: Sub Delete_Every_Other_Row() Dim Rng As Range Set Rng = Application.InputBox("Select the Range (Excluding headers)", "Range Selection", Type:=8) For i = Rng.Rows.Count To 1 Step -2 If i Mod 2 = 0 Then Rng.Rows(i).Delete End If Next i End Sub

Press F5. This will run the code and another window will pop-up.

Select the range of data and click OK. If you have data in cells ranging from A1-B9, you can drag and drop over those cells to select them.

What's your reaction?

Comments

https://tupko.com/assets/images/user-avatar-s.jpg

0 comment

Write the first comment for this!