Screen updating

Use this code template as a starting point (the error handler ensures that these properties are turned back on at the end of the sub, even if it errors) Sub Your Sub() On Error Go To EH Application. Select Next i 'get results results = "Screen Updating not disabled: " & Format(Time - start Time, "hh:mm:ss") & " seconds" start Time = Time 'scenario 2 - screenupdating disabled Application.

Screen Updating = False 'swap between sheets 1/2 (need both sheets or this will crash) For i = 1 To numb Switches Sheets(1 (i Mod 2)). Screen Updating = True 'get results for part two results = results & vb Cr Lf & "Screen Updating IS disabled: " & Format(Time - start Time, "hh:mm:ss") & " seconds" 'show results Msg Box results End Sub Firstly I've been using the script written by Richie (UK) Post #7 Here It simply iterates through a loop changing the value of i in one cell.

This means that the Excel screen can look like it has "gone crazy" while the macro is running.

One thing you may want to do with your macro to make it run faster and to prevent distracting flashes on the screen is to turn off screen updating while the macro is running.

The following macro lines will, respectively, turn off screen updating and then turn it back on in a VBA macro.

The idea is to use the first line near the beginning of your macro, and then use the second line near the end.

This code block sets up what happens when the buttons on Sheet1 are clicked.

This tip (9151) applies to Microsoft Excel 2007, 2010, and 2013.

You can find a version of this tip for the older menu interface of Excel here: Turning Off Screen Updating.

When you run this example, you can compare the respective running times, which are displayed in the message box. Screen Updating = True For i = 1 To 2 If i = 2 Then Application.

Screen Updating = False start Time = Time Worksheets("Sheet1").

74 comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*