Home> Topics> excel> body text

Detailed Excel Example Countdown

WBOY
Release: 2022-12-07 17:03:01
forward
4156 people have browsed it

This article brings you relevant knowledge aboutexcel, which mainly introduces how to make a countdown card. Let’s take a look at it together. I hope it will be helpful to everyone.

Detailed Excel Example Countdown

Related learning recommendations:excel tutorial

In daily work, there are often some countdown applications, such as common distance There are still n days until the college entrance examination, n days until the end of the project, etc. Use the date function in Excel combined with the VBA code to force refresh to create a countdown card.

Let’s look at the effect first:

Detailed Excel Example Countdown

Let’s take a look at the specific steps:

Step 1 Assume that the holiday end date is 2022 At 0:00 on September 14th, enter the following formula in cell C2 to get the remaining integer days.

=INT("2022-9-14"-NOW())&"天"
Copy after login

Step 2 Set the custom format of D2 cell to:

hh hour mm minute ss second

Detailed Excel Example Countdown

Then in cell D2 Enter the following formula in:

="2022-9-14"-NOW()
Copy after login

Although the NOW function is a volatile function, if no operation that can trigger recalculation is performed in the worksheet, the formula results cannot be automatically refreshed in real time, so a scheduled refresh function needs to be added. VBA code.

Step 3 Press the key combination to open the VBE editor, click the [Insert] → [Module] command, and click in the [Project Explorer] to select the "Module 1" just inserted. ”, enter the following code in the code window on the right.

Sub Macro1() Application.OnTime Now + TimeValue("00:00:01"),"Macro1" Calculate End Sub Private Sub workbook_open() Macro1 End Sub
Copy after login

Detailed Excel Example Countdown

The "00:00:01" in the code means that the refresh time is 1 second, which can be set as needed in actual use. For example, if you want to set the refresh time to 1 minute, you can modify this part to "00:01:00".

Step 4 Click to select "ThisWorkbook" in [Project Explorer], enter the following code in the code window on the right, and then press the F5 key to achieve the countdown effect in the cell.

Private Sub workbook_open() Call Macro1 End Sub
Copy after login

Detailed Excel Example Countdown

Detailed Excel Example Countdown

Finally save the file as an Excel macro-enabled workbook, that is, xlsm format.

When you open the file again, if a security warning appears as shown in the figure, remember to click the [Enable Content] button.

Detailed Excel Example Countdown

After the production is completed, you can open Excel and watch the time decrease little by little, and the longing for someone becomes stronger and stronger...

Related learning recommendations:excel tutorial

The above is the detailed content of Detailed Excel Example Countdown. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:excelhome.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!