【问题标题】:Compare unknown time stamps in VBA?比较VBA中的未知时间戳?
【发布时间】:2015-12-21 19:21:40
【问题描述】:

我有时间戳格式为 MM/DD/YYYY hh:mm:ss 的工作表

我希望能够复制两个不同工作表中的两个时间戳匹配的行,误差范围为 +1 秒。因此,如果我有一个时间为 12:14:13 的时间戳,它将找到时间为 12:14:13 或 12:14:14 的时间戳的匹配项。我不想要 ±1 秒的误差范围,因为它可能与错误的测量读数相匹配。我无法事先知道时间戳。

到目前为止,我只编写了将时间戳与文本完全匹配的代码:

For i = 1 To counter 
'counter is the number of matches I want to find
    For Each cell In Range("C4:C" & LastRow)
'dateArray contains the timestamps to be matched
        If cell.Text = dateArray(i) Then
            Sheets("AlarmData").Range("BA" & cell.Row).Copy
            Sheets("Sensor_HWare_Alarms").Range("R" & i).PasteSpecial
            Exit For
        End If
    Next cell
Next

【问题讨论】:

    标签: vba excel date timestamp


    【解决方案1】:

    要结束您的 +1 秒窗口,我将使用 Time(hour, minute,second) 将时间添加一秒,如下面的帖子所示:https://stackoverflow.com/a/8875661/5692872

    【讨论】:

      猜你喜欢
      • 2012-07-09
      • 1970-01-01
      • 2015-09-22
      • 2017-06-24
      • 2018-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多