【发布时间】: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
【问题讨论】: