Pause

brianfosterblack

Active Member
Joined
Nov 1, 2011
Messages
251
The following macro is supposed to display the scores of a competition on a screen, moving down the scores until all have been displayed.
It worked fine in Excel 2003 but in 2007 or 2010 the screen does not refresh after the cursor has moved down to the fouth or fifth line of the results.

Sub LoopDisplayView()
Dim PauseTime, Start, Finish, TotalTime
Do Until ActiveCell = ""
If ActiveCell = "" Then
Exit Sub
Else
PauseTime = Range("display!AA4") ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
ActiveCell.Offset(1, 0).Range("A1").Select
End If
Loop
End Sub

The above is a subroutine of a macro which then sorts the results into categories and classifications and shows all these before starting again. any idea what I am doing wrong?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Your code worked for me in Excel 2007. I used a pause of 1 second and 10 rows of data. Maybe try:

Rich (BB code):
Sub LoopDisplayView()
    Dim PauseTime, Start, Finish, TotalTime
    Do Until ActiveCell = ""
        If ActiveCell = "" Then
            Exit Sub
        Else
            PauseTime = Range("display!AA4") ' Set duration.
            Start = Timer ' Set start time.
            Do While Timer < Start + PauseTime
            Loop
            Finish = Timer ' Set end time.
            TotalTime = Finish - Start ' Calculate total time.
            DoEvents
            ActiveCell.Offset(1, 0).Range("A1").Select
        End If
    Loop
End Sub
 
Upvote 0
Andrew,

My mistake, my macro was stopping on line 11 or 12 so it might not have had a problem with your 10 lines of data.
Adding in the DoEvents has resolved the problem so thank you very much.
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,855
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top