Delete Every Other Row

This post will guide you how to delete every other row by filter command in Excel. How do I delete every other row in a selected range on a worksheet by Excel VBA Macro.

Delete Every Other Row with Filter command

To delete every other row in Excel, you need to filter alternate rows, and then select those rows, and delete them at once. So you need to create a helper column using MOD function with ROW function, just do the following steps:

#1 type the formula =MOD(ROW(),2) in one cell next to your original data, and press enter key, then drag the auto fill handler over other cells to generate 0,1 numbers in each cells.

delete every other row1

#2 select the helper column, go to DATA tab, Click Filter command under Sort & Filter group. The drop-down filter arrows will appear in header cells.

delete every other row2

#3 click the filter arrow in the helper column, and select the 0 check box from the filter drop down list.

delete every other row3

#4 you will see that all “1” rows are hidden, select all the visible “0” rows, then right-click on the selection range, and click Delete Row.

delete every other row4

delete every other row5

#5 all rows with “0” values are removed. Then click the Filter button again on the helper column to remove auto-filter.

delete every other row6

#6 you can delete the helper column.

delete every other row7

Delete every other row with VBA

You can also use an Excel VBA Macro to delete every other row. Do the following steps:

#1 click on “Visual Basic” command under DEVELOPER Tab.

Get the position of the nth using excel vba1

#2 then the “Visual Basic Editor” window will appear.

#3 click “Insert” ->”Module” to create a new module.

convert column number to letter3

#4 paste the below VBA code into the code window. Then clicking “Save” button.

delete every other row8

Sub DeleteEveryOtherRow()
    Dim r As Range
    Dim IR As Range

    Set IR = Application.Selection
    Set IR = Application.InputBox("Select one Range :", "Delete Every Other Row", IR.Address, Type:=8)
    Application.ScreenUpdating = False
    For i = IR.Rows.Count To 1 Step -2
        Set r = IR.Cells(i, 1)
        r.EntireRow.Delete
    Next
    Application.ScreenUpdating = True
End Sub

#5 back to the current worksheet, then run the above excel macro. Click Run button.

delete every other row9

#6 Select one range that you want to delete every other row.

delete every other row10

#7 let’s see the result.

delete every other row11


Related Functions

  • Excel ROW function
    The Excel ROW function returns the row number of a cell reference.The ROW function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the ROW function is as below:= ROW ([reference])….
  • Excel MOD function
    he Excel MOD function returns the remainder of two numbers after division. So you can use the MOD function to get the remainder after a number is divided by a divisor in Excel. The syntax of the MOD function is as below:=MOD (number, divisor)….
Related Posts
VBA Macro For VLOOKUP From Another Sheet
vba macro for vlookup from another sheet1

In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you how to use VBA code to vlookup data ...

How To Insert Comments in Protected Worksheet in Excel
insert commetns in protected workshee3

This post will show you how to allow comments in a protected worksheet in Excel. You can easily to insert comments into cells in a normal worksheet in Excel, but if want to insert a comment in a worksheet that ...

How To Convert Text to Upper Cases(Using VBA) in Excel
convert text to upper cases1

This post will show you how to switch from lower case to upper case in Excel. and I am going to show you two different ways of converting text to upper cases using formula or VBA macro in Excel 2013,Excel ...

How To Hide Every Other Row in Excel (Using VBA)
hide every other row1

This post will show you how to hide alternate rows or columns in Excel or how to hide every third, fourth, fifth row or column in Excel. If you want to hide every other row in your current worksheet, how ...

How to Disable the Save As Prompt in Excel
disable save as prompt1

This post will show you how to use a VBA Macro to save an Excel file and overwrite any existing file without a prompt so that you are going to get the little window that says file already exists do ...

How to Count Cells that Contain even or odd numbers in Excel
count cells that contain even numbers5

This post will guide you how to count the number of cells that contain odd or even numbers within a range of cells using a formula in Excel 2013/2016.How do I count cells that contain odd numbers through the use ...

How to Count Cells that Contain negative Numbers in Excel

This post will guide you how to count the number of cells that contain negative numbers within a range of cells using a formula in Excel 2013/2016.You can count the number of negative numbers in your data using easy functions ...

How to Count Cells Are Not Blank or Empty in Excel
count non blank nonempty cells5

This post will guide you how to count cells that are not blank or empty in a given range cells using a formula in Excel 2013/2016.How do I count the number of cells that are not blank in a particular ...

How to Count Cells Less Than a Specific Value in Excel
count cells lessr than5

This post will guide you how to count the number of cells less than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are less than a specific ...

How to Count Cells Greater Than a Specific Value in Excel
count cells greater than 5

This post will guide you how to count the number of cells greater than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are greater than a specific ...

Sidebar