smooth countdown

plane_nerd

New Member
Joined
Dec 23, 2011
Messages
21
greetings all, sorry if this is covered somewhere else if it is really basic.

i have a macro that loops through calculating to make a count-down timer work. the problem with it is that the screen flickers each time it calculates. It runs roughly like this:

Sub Countdown ()
For i = 1 to 100
Worksheets("Sheet2").Cells(i,1).Value = i
WaitHours = 0
WaitMins = 0
WaitSecs =1
Calculate
Next i
End Sub

Is there a way to smooth it out or make the code simpler?

Thanks in advance
K. B.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi & Welcome to the Board,

The typical way would be by adding application.screenupdating...

Code:
Sub Countdown()
    Application.ScreenUpdating = False
    For i = 1 To 100
        Worksheets("Sheet2").Cells(i, 1).Value = i
        WaitHours = 0
        WaitMins = 0
        WaitSecs = 1
        Calculate
    Next i
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
thanks for reply so quickly jeff,

i tried something like that code but i need to see the effects of the countdown

thanks
K. B.
 
Upvote 0
Can you please explain what you are trying to accomplish?

I run the code and it records 1 to 100 in A1:A100...

What is suppose to happen for you?
 
Upvote 0
Please do not do that...I did not request the workbook.

If you could kindly explain on the message board what you are trying to do this does more than one thing.

First, others may like to follow this thread as it could help them with something they are working on...

Second, if you work on the message board this ensure a wider group of viewer's could potentially be looking at the query and maybe it can be resolved better or even more expeditously...
 
Upvote 0
sorry, i just sent it,

so what i want is a countdown, therefore, it needs to update each second. the macro that was in my original post was the only way i could get it to update each second. the main problem is when it calculates the screen flickers, which is what i want to avoid. application.screenupdating won't solve the problem because i need to see the result of each calculate

K.B.
 
Upvote 0
This description still does not do it for me...

Can you try a clearer description which will explain the what, why, when, how, etc., and post the link to the workbook here...?
 
Upvote 0
Maybe something like this...

Code:
Sub ShowProgress()
    Dim lngLoop As Long
    For lngLoop = 1 To 100
        Sheets("Sheet1").Range("A1") = Now
        Application.Wait Now + TimeValue("00:00:01")
    Next lngLoop
End Sub

And maybe in the ThisWorkbook module...

Code:
Private Sub Workbook_Open()
    Sheets("Sheet1").Range("A1").Formula = "=NOW()"
End Sub

...that way when the workbook first open A1 would get the current time or you could just have it hard code the time on open
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,847
Members
452,361
Latest member
d3ad3y3

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