![]() |
I need a macro that will delete every other row in excel.
I tried the following but no luck. If I just create a macro to delete a row
it places a 2 where I have the variable row. I just need to increment the row. Sub delete() ' delete Macro ' Dim row, endrow As Integer row = 2 endrow = 120 ' If row < endrow Then Rows("row:row").Select Selection.delete Shift:=xlUp row = row + 1 End If End Sub |
I need a macro that will delete every other row in excel.
Sub delete()
' delete Macro ' Dim startrow as long, endrow As long Dim rw as Long startrow = 2 endrow = 120 ' for rw = endrow to row step -1 Rows(rw).delete Shift:=xlUp Next End If End Sub or Sub Delete() dim startrow as long, endrow as Long startrow = 2 endrow = 120 rows(startrow).Resize(endrow - startrow + 1) _ .entireRow.Delete End Sub -- Regards, Tom Ogilvy "Russ T" <Russ wrote in message ... I tried the following but no luck. If I just create a macro to delete a row it places a 2 where I have the variable row. I just need to increment the row. Sub delete() ' delete Macro ' Dim row, endrow As Integer row = 2 endrow = 120 ' If row < endrow Then Rows("row:row").Select Selection.delete Shift:=xlUp row = row + 1 End If End Sub |
All times are GMT +1. The time now is 08:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com