Deleting rows in Excel

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.
 
E

Earl Kiosterud

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.
 
H

Harald Staff

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top