Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
plh plh is offline
external usenet poster
 
Posts: 48
Default Holding off on screen updates

Is there a way to hold off on screen updates until the end of a macro, when
deleting whole rows?
Here is the code:
Do While Range("A" & r).Value < ""
If (Range("A" & r).Value) = strOldString Then
Application.DisplayAlerts = False
For i = 1 To 5
Range("A" & r).EntireRow.Delete
Next i
Application.DisplayAlerts = True
End If
If IsError(Range("R" & r)) = True Then
Application.DisplayAlerts = False
Range("A" & r).EntireRow.Delete
Application.DisplayAlerts = True
ElseIf Range("R" & r).Value < 1 Then
Application.DisplayAlerts = False
Range("A" & r).EntireRow.Delete
Application.DisplayAlerts = True
Else
r = r + 1
End If
Loop
I takes rather a long time to get through the worksheet, which starts with
upwards of 3000 lines, because the display continually updates, which takes a
small amount of time, but in this case those small amounts add up. Is there a
way to do this without screen updating? If necessary, can I close it and then
refer to the cells and ranges while it is closed?
Thank You,
-plh


--
I keep hitting "Esc" -- but I'm still here!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Holding off on screen updates

Application.ScreenUpdating = False
--
Gary''s Student


"plh" wrote:

Is there a way to hold off on screen updates until the end of a macro, when
deleting whole rows?
Here is the code:
Do While Range("A" & r).Value < ""
If (Range("A" & r).Value) = strOldString Then
Application.DisplayAlerts = False
For i = 1 To 5
Range("A" & r).EntireRow.Delete
Next i
Application.DisplayAlerts = True
End If
If IsError(Range("R" & r)) = True Then
Application.DisplayAlerts = False
Range("A" & r).EntireRow.Delete
Application.DisplayAlerts = True
ElseIf Range("R" & r).Value < 1 Then
Application.DisplayAlerts = False
Range("A" & r).EntireRow.Delete
Application.DisplayAlerts = True
Else
r = r + 1
End If
Loop
I takes rather a long time to get through the worksheet, which starts with
upwards of 3000 lines, because the display continually updates, which takes a
small amount of time, but in this case those small amounts add up. Is there a
way to do this without screen updating? If necessary, can I close it and then
refer to the cells and ranges while it is closed?
Thank You,
-plh


--
I keep hitting "Esc" -- but I'm still here!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Holding off on screen updates

You almost answered your own question <g
Application.ScreenUpdating = False
'Your Code
Application.ScreenUpdating = True

or if you have a lot of formulas slowing you down:

Dim CalcMode
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.DisplayAlerts = False
End With
'Your Code
With Application
.Calculation = CalcMode
.ScreenUpdating = True
.DisplayAlerts = True
End With

HTH

Charles
plh wrote:
Is there a way to hold off on screen updates until the end of a macro, when
deleting whole rows?
Here is the code:
Do While Range("A" & r).Value < ""
If (Range("A" & r).Value) = strOldString Then
Application.DisplayAlerts = False
For i = 1 To 5
Range("A" & r).EntireRow.Delete
Next i
Application.DisplayAlerts = True
End If
If IsError(Range("R" & r)) = True Then
Application.DisplayAlerts = False
Range("A" & r).EntireRow.Delete
Application.DisplayAlerts = True
ElseIf Range("R" & r).Value < 1 Then
Application.DisplayAlerts = False
Range("A" & r).EntireRow.Delete
Application.DisplayAlerts = True
Else
r = r + 1
End If
Loop
I takes rather a long time to get through the worksheet, which starts with
upwards of 3000 lines, because the display continually updates, which takes a
small amount of time, but in this case those small amounts add up. Is there a
way to do this without screen updating? If necessary, can I close it and then
refer to the cells and ranges while it is closed?
Thank You,
-plh


--
I keep hitting "Esc" -- but I'm still here!


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
CAE macro for green screen updates with Excel data Sriram Excel Discussion (Misc queries) 1 July 16th 06 04:19 PM
Screen Updates on a userform Neil Excel Programming 2 October 17th 03 01:23 PM
Screen Updates not working ? Neil[_14_] Excel Programming 1 October 16th 03 12:59 PM
Turning off all screen updates during a Solver routine Tony Scullion Excel Programming 3 August 15th 03 08:09 PM
macros and screen updates Tim Laud Excel Programming 5 August 4th 03 01:54 PM


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