Deleting rows in Excel

  • Thread starter Thread starter Grant
  • Start date Start date
G

Grant

Is there a way to delete all the odd or even rows in an
Excel file? I'm dealing with a list of around 30,000
people and I need to delete all the odd rows. Is there a
faster way to delete these other than manually deleting
deleting them.
 
Put in a helper column:
=MOD(ROW(),2)
Use Autofilter to filter to 0 or 1. Select the filtered rows and delete
(Ctrl minus). Remove the filter and helper column.
 
Hi

1 Open the VB editor (Alt F11 or similar).
2 Menu Insert > Module
3 Paste this in:

Sub test()
Dim L As Long
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For L = 40001 To 3 Step -2
Rows(L).Delete
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

4 Return to Excel. Go to your sheet.
5 Run the macro (Tools > Macro menu).Get a coffee.

HTH. Best wishes Harald
 
Back
Top