VBA Excel:一次添加一秒钟 [英] VBA Excel: Add one second to a time

查看:256
本文介绍了VBA Excel:一次添加一秒钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个包含两列的电子表格,其中一列是时间。我使用时间作为关键字将数据加载到字典中。我想查找与特定时间相对应的数据(简单),然后获取下一个数据点,以便我可以比较它们的值。记录数据,使得在大约两个小时的时间内每秒生成一个数据。

I'm working with a spreadsheet with two columns, in which one of the columns is a time. I have loaded the data into a dictionary using the time as a key. I want to look up the data corresponding to a particular time (easy), and then get the next data point so that I can compare their values. The data is recorded such that one piece of data is generated every second over a period of around two hours.

我的问题是,Excel中的VBA是否具有可以自动加一秒钟一次或者我需要手动写一个?

My question is, does VBA in Excel have a function which can automatically add one second to a time? Or do I need to manually write one?

更新:除了下面的答案之外,我还发现DateAdd功能很有用 - 我怀疑这取决于

Update: In addition to the answers below, I have also found the "DateAdd" function useful - I suspect it depends on the version of Excel being used.

推荐答案

您应该可以使用时间(小时,分钟,秒)功能添加一秒到这个时间。

you should be able to use Time(hour, minute,second) function to add a second to the time.

所以添加1秒到一个日期,像 Date(2012,1,16)+时间(0,0 ,1)应该导致值2012-01-16 12:00:01 AM

so to add 1 second to a date with something like Date(2012,1,16) + Time(0,0,1) which should result in a value of "2012-01-16 12:00:01 AM"

这篇关于VBA Excel:一次添加一秒钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆