Saturday, May 11, 2013

How to Insert a Countdown Timer in an Excel Worksheet


1. Open the Excel 2010 worksheet where you want to add a countdown timer. Right-click the cell where you want the timer to go and choose 'Format Cells.' Click 'Custom' on the left side of the window that appears and then select 'h:mm:ss' from the list on the right. Click 'OK' to continue.
2. Hold down 'Alt' and press 'F11' to open up the VBA console. Select your current worksheet from the list on the left side of the console. Click the small arrow next to the 'Insert Userform' button at the top of the screen, which is the second button from the left side, and choose 'Module' from the list of options that appear. Double-click 'Module 1' when it appears in the list.
3. Click the white space on the right side of the screen and enter the following code:Sub Countup()Dim CountDown As DateCountDown = Now TimeValue('00:00:01')Application.OnTime CountDown, 'Realcount'End SubThis code will allow the rest of the code to process once each second.
4. Press enter to access a new line on the page. Enter to following code:Sub Realcount()Dim count As RangeSet count = [E1]count.Value = count.Value - TimeSerial(0, 0, 1)If count
5. Click the 'X' in the upper right corner of the console to close it.
6. Select the cell that you are using for your countdown and enter your desired countdown time. Be sure that you enter the hours, minutes and seconds, even if the hours and minutes are zero. '2:30' is two hours and thirty minutes; '0:2:30' is two minutes and thirty seconds.
7. Click the 'Developer' tab at the top of the screen, and then click the 'Macros' button on the left side of the ribbon. Select 'Countup' from the list and click 'Run.' Your countdown will start and it will continue until it gets to zero, when you will see a message box explaining that the countdown is complete.

Blogger news