在Excel中用快捷键输入“HH:MM:SS”格式的当前时间
时间:2023-10-03 14:41:25
我们知道在Excel单元格中输入当前时间的快捷键是“Ctrl+Shift+;”,但是这种输入方法只能显示小时和分钟,即HH:MM格式的时间。用下面的VBA代码可以实现用上述快捷键输入当前时间时,在单元格中显示的是包含秒的“HH:MM:SS”格式。方法如下:
按Alt+F11,打开VBA编辑器,单击菜单“插入→模块”,将下列代码输入到代码窗口中:
Sub setKey()
Application.OnKey "+^:", "EnterTime"
End Sub
Sub resetKey()
Application.OnKey "+^:"
End Sub
Sub EnterTime()
With ActiveCell
.Value = Time()
.NumberFormat = "hh:mm:ss"
End With
End Sub
运行setkey(),在工作表中选择一个单元格,按快捷键“Ctrl+Shift+;”,将显示HH:MM:SS格式的当前时间,如“20:25:09”。要还原默认的输入方式,运行resetkey()即可。
标签:快捷键,时间,格式,输入,Excel函数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
最新屏蔽 iOS 16 更新描述文件已发布!附上安装和使用方法
2023-09-21 12:18:53
![](https://img.aspxhome.com/file/2023/8/45598_0s.png)
Excel2016中对柱形图数据使用图片填充
2023-06-19 21:23:35
![](https://img.aspxhome.com/file/2023/7/41197_0s.jpg)
小技巧教你取消win7系统锁屏密码
2022-05-06 00:05:46
![](https://img.aspxhome.com/file/2023/5/a316111_0s.png)
通过 Apple ID 登录第三方应用和网站有哪些优点?
2023-08-01 06:35:05
![](https://img.aspxhome.com/file/2023/6/45096_0s.png)
excel2007如何制作下拉列表
2022-11-05 05:58:35
Win10 Mobile 10512安卓应用键盘问题 无需重置也能解决
2023-08-02 05:32:44
![](https://img.aspxhome.com/file/2023/28/a248181_0s.jpg)
如何在Photoshop中制作复古漫画书肖像效果动作
2023-04-21 04:02:50
![](https://img.aspxhome.com/file/2023/5/a211915_0s.png)
WPS文档封面页面怎么添加教学
2022-10-17 22:28:11
![](https://img.aspxhome.com/file/2023/1/a182601_0s.jpg)
Win7电脑出现提示Runtime error怎么解决?
2023-01-03 13:33:23
![](https://img.aspxhome.com/file/2023/27/a232135_0s.jpg)
Win7系统全屏模式玩游戏会死机的解决办法
2022-09-01 13:45:42
![](https://img.aspxhome.com/file/2023/3/a292346_0s.jpg)
win7系统怎么关闭3D加速?
2022-02-14 23:29:45
![](https://img.aspxhome.com/file/2023/1/a275616_0s.jpg)
PPT背景音乐怎么设置从头到尾播放?PPT的音乐从头放到尾的设置方法
2023-01-17 20:22:05
![](https://img.aspxhome.com/file/2023/10/a350455_0s.jpg)
韩博士教程,详细教您韩博士U盘怎么重装win7系统
2022-03-12 09:41:17
![](https://img.aspxhome.com/file/2023/2/a285588_0s.png)
Excel中Sumif函数的使用方法
2022-05-01 17:27:11
在Word中怎么从文档的某页开始插入页码?
2022-06-08 00:38:46
![](https://img.aspxhome.com/file/2023/8/25228_0s.jpg)
金山wps怎么把数学公式设置为红色
2022-02-03 12:41:40
![](https://img.aspxhome.com/file/2023/4/a163974_0s.jpg)
u盘杀毒专家免费版,详细教您如何使用u盘杀毒专家给U盘杀毒
2023-02-28 04:40:01
![](https://img.aspxhome.com/file/2023/3/a294584_0s.png)
Win10系统IE浏览器图标无法删除的解决办法
2023-07-04 23:26:03
![](https://img.aspxhome.com/file/2023/4/a308075_0s.jpg)
马桶mt安装不了怎么办 马桶mt无法安装的解决方法
2022-03-03 15:25:50
![](https://img.aspxhome.com/file/2023/8/a335432_0s.jpeg)
wps表格如何删除重复项
2023-09-23 00:18:30