如何在Excel中显示hh:mm:ss? [英] How to display hh:mm:ss in Excel?
本文介绍了如何在Excel中显示hh:mm:ss?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Excel VBA的新手.我想设置一个循环,以在新单元格中显示每分钟的时间.
I'm new to Excel VBA. I want to set up a loop that will display the time for each minute on the minute in a new cell.
有没有一种方法可以只显示一个单元格中的时间(hh:mm:ss)而看不到它旁边的日期?另外,我想要显示的时区.(例如,新加坡时间,"SGT").
Is there a way to display only the time (hh:mm:ss) in a cell without seeing the date beside it? Also, I'd like the time zone shown. (e.g. Singapore Time, "SGT").
这是我想看到的输出示例:
Here is an example of the output I'd like to see:
23-Oct-13 10:00:00 AM SGT
23-Oct-13 10:01:00 AM SGT
23-Oct-13 10:02:00 AM SGT
23-Oct-13 10:03:00 AM SGT
23-Oct-13 10:04:00 AM SGT
23-Oct-13 10:05:00 AM SGT
23-Oct-13 10:06:00 AM SGT
23-Oct-13 10:07:00 AM SGT
23-Oct-13 10:08:00 AM SGT
23-Oct-13 10:09:00 AM SGT
23-Oct-13 10:10:00 AM SGT
23-Oct-13 10:11:00 AM SGT
23-Oct-13 10:12:00 AM SGT
23-Oct-13 10:13:00 AM SGT
23-Oct-13 10:14:00 AM SGT
23-Oct-13 10:15:00 AM SGT
23-Oct-13 10:16:00 AM SGT
23-Oct-13 10:17:00 AM SGT
23-Oct-13 10:18:00 AM SGT
23-Oct-13 10:19:00 AM SGT
23-Oct-13 10:20:00 AM SGT
...
推荐答案
这样做应该很有趣.:-)
This Should do it, have Fun. :-)
Option Explicit
Sub test()
Dim i&, sTime As Date, TimeStep As Date, Cell As Range
'// Format range cell to 24Hrs
With Range("A1:A1440") '// 24H*60M
.NumberFormat = "HH:MM:SS;@"
End With
Set Cell = [A1] '// first cell to write
sTime = "00:00:00" '// start time
'// Loop 24hrs
TimeStep = "00:01:00" '// time increment
For i = 0 To 1439 ' // 1439 means 1439 cells
Cell.Offset(i, 0).Value = sTime
sTime = sTime + TimeStep
Next i
End Sub
开始
结束
这篇关于如何在Excel中显示hh:mm:ss?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文