Execute a method periodically in VBA

Source: Internet
Author: User

Question 10: how to make the text in the worksheet flash?
A: To make the text flash, you need to periodically execute Program The ontime method can be used to periodically run a program.
'*************************************** ***********
Public runwhen as double
Sub startblink ()
If range ("A1"). Font. colorindex = 2 then
Range ("A1"). Font. colorindex = xlcolorindexautomatic
Else
Range ("A1"). Font. colorindex = 2
End if
Runwhen = now + timeserial (0, 0, 1)
Application. ontime runwhen, "startblink", true
End sub
'*************************************** ***********
Sub stopblink ()
Range ("A1"). Font. colorindex = xlcolorindexautomatic
Application. ontime runwhen, "startblink", false
End sub
In the above programs, you can change the cell or cell area of the parameter A1. When opening a workbook, You need to initialize this program. Therefore, you can place the following Code To the thisworkbook code module.
'*************************************** ***********
Private sub workbook_open ()
Startblink
End sub
When the workbook is closed, you need to cancel the ontime event. Therefore, you need to place the following code in the thisworkbook code module.
'*************************************** ***********
Private sub workbook_beforeclose (cancel as Boolean)
Stopblink
End sub
For more information, see excel.xls. Uploadfiles/2006-8/81151110. rar

The above content comes from
Http://blog.excelhome.net/user1/fanjy/archives/2006/555.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.