VBA records the current system time and is accurate to milliseconds

Source: Internet
Author: User

Want to do a function, click the button once, in the A1 record the current system time, to the exact millisecond. Click the button again at the A2 display, and so on!

For example: This function can be used to do lyrics time!

SubTTT () activecell.selecttt=Timerh=Int(TT/3600) M=Int(TT-3600* h)/ -) s=Int(Tt-h *3600-M * -) SS= Left(TT-Int(TT),4) selection.numberformatlocal="YYYY-MM-DD hh:mm:ss.000"Selection.value= h &":"& M &":"& S &Ssactivecell.offset (1,0). SelectEnd Sub

The above code can actually implement this function, but there is a problem, when more than one screen, point, Button Point, Excel View with the Click Button new content screen down, the button can not see, you can not change the position of the cursor. So I improved the following code again:

Subtesttime ()DimTT, NTT=Timern= Range ("A65536"). End (Xlup). ROWH=Int(TT/3600) M=Int(TT-3600* h)/ -) s=Int(Tt-h *3600-M * -) SS= Left(TT-Int(TT),4) Cells (n+1,1). NumberFormatLocal ="hh:mm:ss.000"Cells (n+1,1) = h &":"& M &":"& S &SSEnd Sub

This method can perfectly record the time of the lyrics.

Reference Source: http://www.excelpx.com/thread-329989-1-1.html

VBA records the current system time and is accurate to milliseconds

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.