Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default deleting rows, takes a long time!

Hi, i received pieces of this code below to delete all the
rows in a spreadsheet where in a certain column the letter
d is present and in another column that row is blank, the
code below works great, when its ran in a group of other
modules, but if i run this particular mod all by its self
it takes it self a long time to run. does anyone have a
clue why? or how i can speed it up as if it was run from a
group of modules. screen updating is turned off, along
with calculation when this macro runs. see code below:

Application.ScreenUpdating = False

Sheets("report").Select

Sheets("losstnspreadsheet").Select
ActiveSheet.Range("A1").Select
Selection.End(xlDown).Offset(1, 0).Select
myrow = Selection.Row - 1

Dim findstring As String
findstring = "D"
Set b = Range("G2:G" & myrow).Find(What:=findstring _
& "*", LookAt:=xlWhole)
While Not (b Is Nothing)
b.EntireRow.Delete
Set b = Range("G2:G" & myrow).Find(What:=findstring _
& "*", LookAt:=xlWhole)
Wend

On Error Resume Next 'In case there are no blank rows
ActiveSheet.Range("G2:G" & myrow).SpecialCells
(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0

ActiveSheet.Range("A1").Select
Application.ScreenUpdating = True
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default deleting rows, takes a long time!

Try putting something like this near the top.

Sheets("report").DisplayPageBreaks = False

If you can see those dotted lines, then excel wants to determine where they
should be put--each time you delete a row. If you turn it off, excel won't try
to determine this.

Nick wrote:

Hi, i received pieces of this code below to delete all the
rows in a spreadsheet where in a certain column the letter
d is present and in another column that row is blank, the
code below works great, when its ran in a group of other
modules, but if i run this particular mod all by its self
it takes it self a long time to run. does anyone have a
clue why? or how i can speed it up as if it was run from a
group of modules. screen updating is turned off, along
with calculation when this macro runs. see code below:

Application.ScreenUpdating = False

Sheets("report").Select

Sheets("losstnspreadsheet").Select
ActiveSheet.Range("A1").Select
Selection.End(xlDown).Offset(1, 0).Select
myrow = Selection.Row - 1

Dim findstring As String
findstring = "D"
Set b = Range("G2:G" & myrow).Find(What:=findstring _
& "*", LookAt:=xlWhole)
While Not (b Is Nothing)
b.EntireRow.Delete
Set b = Range("G2:G" & myrow).Find(What:=findstring _
& "*", LookAt:=xlWhole)
Wend

On Error Resume Next 'In case there are no blank rows
ActiveSheet.Range("G2:G" & myrow).SpecialCells
(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0

ActiveSheet.Range("A1").Select
Application.ScreenUpdating = True


--

Dave Peterson

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
deleting takes too long Howiek1 Excel Worksheet Functions 2 January 17th 11 12:58 PM
Clearing cells takes long, long time unclemuffin Excel Discussion (Misc queries) 9 August 17th 07 02:22 AM
Loading MS Query takes a long time TonyL Excel Worksheet Functions 0 August 14th 06 08:30 AM
Excel Help takes a very long time to load Sam Pack via OfficeKB.com Excel Discussion (Misc queries) 4 March 4th 06 12:02 AM
Save takes long time Jan Excel Discussion (Misc queries) 2 February 15th 06 06:01 PM


All times are GMT +1. The time now is 02:34 PM.

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

About Us

"It's about Microsoft Excel"