ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete every other row in a 2007 spreadsheet (https://www.excelbanter.com/excel-programming/410197-delete-every-other-row-2007-spreadsheet.html)

Legal Learning

Delete every other row in a 2007 spreadsheet
 
I need to delete every other row in a 2000 row Excel 2007 spreadsheet. Could
someone help me with the code with this. I am ok with Word VBA but NOT Excel.


Thanks!

KC Rippstein hotmail com>

Delete every other row in a 2007 spreadsheet
 
Sub deleteAlternatingRows()

For i = Cells(Rows.Count, "a").End(xlUp).Row To 2 Step -2
Rows(i).Delete
Next i

End Sub

--
Please remember to indicate when the post is answered so others can benefit
from it later.


"Legal Learning" wrote:

I need to delete every other row in a 2000 row Excel 2007 spreadsheet. Could
someone help me with the code with this. I am ok with Word VBA but NOT Excel.


Thanks!


Zack Barresse

Delete every other row in a 2007 spreadsheet
 
This is REALLY easy w/o VBA...

Use a helper (blank) column, insert a column if you'd like
At the start of your data (assuming you are not skipping blank rows, if so,
this isn't for you) put this formula =MOD(ROW(),2)
Copy down your entire data set
Filter on that column (Home tab | Editing group | Sort & Filter button) for
whichever odd/even row you want to delete (0 or 1)
Select the visible rows
Hit Ctrl + - (that is a minus sign)
Confirm delete entire row
Delete helper column

HTH

--
Zack Barresse



"Legal Learning" wrote in message
...
I need to delete every other row in a 2000 row Excel 2007 spreadsheet.
Could
someone help me with the code with this. I am ok with Word VBA but NOT
Excel.


Thanks!




All times are GMT +1. The time now is 02:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com