LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Speeding up a delete rows Macro

Below is the code I use to delete rows from a spreadsheet based on multiple
criteria. (column 16 is empty, column 2 to 15 is empty, column 1 contains
user ID)

The macro work great, but the spreadsheet is about 150K rows and it takes 15
to 20 minutes to run. I was hoping that someone would know how to make the
macro faster.

I cannot sort the data and the order is very important in the next steps...
I now delete the blank rows in column 16 one at a time, and they are some
times clustered 30 rows together...was thinking if I could modify the code to
delete blocks of rows ratther that one at a time it might speeed up the
execution

Thanks


Sub C_Remove_Blank_Rows()
Application.ScreenUpdating = False
Cells(200000, 14).Select
Selection.End(xlUp).Select
EndRow = ActiveCell.Row
Do Until EndRow < 2
If Cells(EndRow, 16) < Empty Then GoTo No_Find
Rows(EndRow & ":" & EndRow).Select: Selection.Delete
Shift:=xlUp
GoTo No_Find2
No_Find:
Set r = Range(Cells(EndRow, 1), Cells(EndRow, 15))
r.Select
For Each r In Selection
If IsEmpty(r) Then
Else
GoTo No_Find2
Exit Sub
End If
Next
Rows(EndRow & ":" & EndRow).Select: Selection.Delete
Shift:=xlUp
GoTo No_Find3
No_Find2:
If Left(Cells(EndRow, 1), 9) < " USER ID" Then GoTo No_Find3
Rows(EndRow & ":" & EndRow).Select: Selection.Delete
Shift:=xlUp
No_Find3:
EndRow = EndRow - 1
Loop
Application.ScreenUpdating = True
End Sub

--
Helping Is always a good thing
 
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
Speeding up Hide rows code caroline Excel Programming 2 February 11th 09 06:41 PM
Speeding up execution of a Macro QuietMan Excel Programming 4 December 21st 07 09:13 PM
Speeding up Macro jayklmno Excel Programming 4 October 11th 06 03:54 AM
Speeding Up Macro in VBA VexedFist[_2_] Excel Programming 4 October 4th 06 09:13 PM
speeding up a macro Brenda[_5_] Excel Programming 4 August 21st 03 12:56 AM


All times are GMT +1. The time now is 04:13 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"