![]() |
Loops for deleting rows
I need to go through a spreadsheet and delete all odd rows.....I have
sooooo many rows that it takes forever and crashes....I need some VBA which doesnt crash my spreadsheet!!! Any ideas?? Thanks Dani --- Message posted from http://www.ExcelForum.com/ |
Loops for deleting rows
Dani,
Try something like the following: Dim LastRow As Long Dim RowNdx As Long Application.ScreenUpdating = False Application.Calculation = xlCalculationManual LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp) If LastRow Mod 2 = 0 Then LastRow = LastRow + 1 End If For RowNdx = LastRow To 1 Step -2 Rows(RowNdx).Delete Next RowNdx Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "daniB " wrote in message ... I need to go through a spreadsheet and delete all odd rows.....I have sooooo many rows that it takes forever and crashes....I need some VBA which doesnt crash my spreadsheet!!! Any ideas?? Thanks Dani --- Message posted from http://www.ExcelForum.com/ |
Loops for deleting rows
ActiveSheet.UsedRange.EntireRow.Delete
-- Regards, Tom Ogilvy "daniB " wrote in message ... I need to go through a spreadsheet and delete all odd rows.....I have sooooo many rows that it takes forever and crashes....I need some VBA which doesnt crash my spreadsheet!!! Any ideas?? Thanks Dani --- Message posted from http://www.ExcelForum.com/ |
Loops for deleting rows
Missed the "odd" in "all odd rows"
So don't use my suggestion. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... ActiveSheet.UsedRange.EntireRow.Delete -- Regards, Tom Ogilvy "daniB " wrote in message ... I need to go through a spreadsheet and delete all odd rows.....I have sooooo many rows that it takes forever and crashes....I need some VBA which doesnt crash my spreadsheet!!! Any ideas?? Thanks Dani --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 06:57 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com