Deleting Multiple Rows...URGENT

gjtaylor10

New Member
Joined
Aug 18, 2010
Messages
3
I have over 40,000 rows of information that i need to be trimmed down. Is there a easy way to delete every OTHER row of information? I need help fast.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Code:
Sub DeleteRows()
StartRow = 1 '<-- Enter First Row To Be Deleted
EndRow = 100 '<-- Enter Last Row To Be Deleted
 
currR = StartR - 2
Do
    currR = currR + 2
    Rows(currR).Delete Shift:=xlUp
Loop Until currR > EndR - 2
End Sub

By the way... Always save your data before you run code that deletes data... THERE IS NO UNDO FOR MACROS
 
Upvote 0
does this help?

Sub Delete_Everyother_Row()
Dim rng As Range
Application.ScreenUpdating = False
Columns("A:A").Insert
Set rng = Range("A10:A40000")
With rng
.FormulaR1C1 = "=IF(MOD(ROW(),2)=0,1,"""")"
.SpecialCells(xlCellTypeFormulas, 2).EntireRow.ClearContents
End With
Columns("A:A").Delete
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Alt+F11 to open the VBA editor
From the VBA menu select Insert\ Module
Paste the code below in the VBA Edit window

Test this on a copy of your data to make sure it's what you really want.

Code:
Sub Delete_Everey_Other_Row()

    Dim Lastrow As Long, r As Long
    
    Lastrow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    
    Application.ScreenUpdating = False
    For r = Lastrow To 1 Step -2
        Rows(r).Delete
    Next r
    Application.ScreenUpdating = False
    
End Sub
 
Upvote 0
Im unaware on how to work with Macros. I have windows 7 with excel 2007. How do i run the macro or enter the code.
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top