Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Excel Worksheet Functions 1 November 12th 08 01:39 PM
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
deleting hidden rows so i can print only the rows showing?????? jenn Excel Worksheet Functions 0 October 6th 05 04:05 PM
Loops to delete rows Mike Etzkorn Excel Programming 6 November 14th 03 05:26 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"