想做个功能,点一次按钮,就在A1记录一次当前系统时间,要精确到毫秒的。再点一次按钮就在A2显示,以此类推!

例如:这个功能可以用来做歌词记时间!

Sub ttt()
ActiveCell.Select
tt = Timer
h = Int(tt / )
m = Int((tt - * h) / )
s = Int(tt - h * - m * )
ss = Left(tt - Int(tt), )
Selection.NumberFormatLocal = "yyyy-mm-dd hh:mm:ss.000"
Selection.Value = h & ":" & m & ":" & s & ss
ActiveCell.Offset(, ).Select
End Sub

上面的代码确实可以实现这个功能,可是还有个问题,当超过一个屏幕的时候,点着点着,按钮点不到了,excel视图随着点击按钮新的内容屏幕往下移了,按钮看不到了,你不能改变光标位置。所以我再次改良如下代码:

Sub testTime()
Dim tt, n
tt = Timer
n = Range("A65536").End(xlUp).Row
h = Int(tt / )
m = Int((tt - * h) / )
s = Int(tt - h * - m * )
ss = Left(tt - Int(tt), )
Cells(n + , ).NumberFormatLocal = "hh:mm:ss.000"
Cells(n + , ) = h & ":" & m & ":" & s & ss
End Sub

这个方法可以完美的记录歌词的时间了。

参考出处:http://www.excelpx.com/thread-329989-1-1.html

VBA记录当前系统时间并精确到毫秒的更多相关文章

  1. 【Java】得到当前系统时间,精确到毫秒

    import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Ma ...

  2. Java得到当前系统时间,精确到毫秒的几种方法

    import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Ma ...

  3. PHP时间戳与时间相互转换(精确到毫秒)

    原文:PHP时间戳与时间相互转换(精确到毫秒) /** 获取当前时间戳,精确到毫秒 */ function microtime_float(){   list($usec, $sec) = explo ...

  4. oracle获得当前时间,精确到毫秒并指定精确位数

    oracle获得当前时间的,精确到毫秒   可以指定精确豪秒的位数 select to_char(systimestamp, 'yyyymmdd hh24:mi:ss.ff ') from dual; ...

  5. gettimeofday() 获取系统时间,精确到微秒 这个似乎只能在linux 下用,不能在windows 下用

    struct timeval{ long int tv_sec; // 秒数 同time(NULL) 的返回值 long int tv_usec; // 微秒数 10 的6次方 }; struct t ...

  6. Linux获取系统当前时间(精确到毫秒)

    #include <stdio.h> #include <time.h> #include <sys/time.h> void sysLocalTime() { t ...

  7. 怎么使用Delphi获取当前的时间,精确到毫秒

    先介绍一个可能比较常用的方法,获取当前时间 var datetime: string; begin datetime:= FormatDateTime('yyyy-mm-dd hh:mm:ss', N ...

  8. C/C++ 获取系统时间 到秒 || 到毫秒

    string getNowSysTime(string &outPut) { ] = {}; struct timeval tv; struct timezone tz; struct tm ...

  9. mysql 时间类型精确到毫秒、微秒及其处理

    一.MySQL 获得毫秒.微秒及对毫秒.微秒的处理 MySQL 较新的版本中(MySQL 6.0.5),也还没有产生微秒的函数,now() 只能精确到秒. MySQL 中也没有存储带有毫秒.微秒的日期 ...

随机推荐

  1. web.xml配置整理

    虽然是做web开发,但是web中的很多配置有的时候却不是很清楚,只是知道怎么配置,于是就把在网上看到各种关于web.xml的东西整理一下: web.xml中url-pattern的3种写法 1完全匹配 ...

  2. J - 组合

    J - 组合 Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%lld & %llu Description 有两 ...

  3. 异常:The JSP specification requires that an attribute name is preceded by whitespace

    The JSP specification requires that an attribute name is preceded by whitespace: 其实这句话翻译就是 属性后面要必须有空 ...

  4. 智能家居DIY-空气质量检测篇-获取温度和湿度篇

    目录 智能家居DIY-空气质量检测篇-获取空气污染指数 前言 话说楼主终于升级当爸了,宝宝现在5个月了,宝宝出生的时候是冬天,正是魔都空气污染严重的时候,当时就想搞个自动开启空气净化器,由于种种原因一 ...

  5. TFS 中工作项的定制-修改工作流

    我们都会用到TFS中的工作项.一般来说,最主要的会用到任务.bug这些工作流来进行项目管理里.但我们发现,实际上,有些模板中的工作流并不能完全符合我们的需要,因此我们会进行工作流的定制操作.下面就会通 ...

  6. js自动补全

    <!doctype html> <html> <style> body { margin-left: 0px; margin-top: 0px; margin-ri ...

  7. jQuery-Ajax-Timeout属性不生效的问题

    async必须设置为async:ture,timeout才生效: 如果设置为async:false,则锁住浏览器,禁止一切操作,直到请求有返回结果.

  8. [note]CRT&exCRT

    中国剩余定理 别人的blog 假设现在有关于x的同余方程组(p1,p2均为质数) \(x=a_1\pmod {p_1}\) \(x=a_2\pmod {p_2}\) 可以转化成如下形式 \(x=a_1 ...

  9. Nvidia NVENC 硬编码预研总结

    本篇博客记录NVENC硬编码的预研过程 github:  https://github.com/MarkRepo/NvencEncoder 步骤如下: (1)环境搭建 (2)demo编译,测试,ARG ...

  10. python selenium cookie 登录

    概要: 1.正常登录,使用selenium获取cookie: 2.保存cookie: 3.使用cookie登录. 4.python--2.7,selenium--3.4.1 步骤1 正常登录,使用se ...