Hello all,
I am looking for some help either A) troubleshooting an existing macro or B) finding another (better?) method for solving the same problem.
Because my write-up has proven to be rather lengthy to explain, here is the "TLDR" version: I have a macro that is supposed to fill in gaps in a data set that has a time sequence. It has some strange bugs and isn't functioning properly. It is included at the bottom of the post. Any idea what is wrong? Should I be doing this a different way? Note: This problem has persisted between two computers, one using Windows 7 and Excel 2010, and another using Windows 7 and Excel 2013.
For those of you who are interested in the full explanation and everything I know so far, here goes:
I am working with large data sets (hundreds of thousands of lines+) that include a time stamp for each line. Each time stamp occurs after 1 second. Due to what I believe is hardware limitations with our data collectors, there is a missing value every so often (~90 line increments). To have a continuous time series I have been working with a macro that inserts a row for each missing time value and inserts the proper time stamp. Note: This problem has persisted between two computers, one using Windows 7 and Excel 2010, and another using Windows 7 and Excel 2013.
For example:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 453"]
<tbody>[TR]
[TD]5/29/2014 18:19:11[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:12[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:13[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:14[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:15[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:21[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:22[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:23[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:24[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:25[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
Between line 5 and line 6 there are 5 missing data points (and therefore a discontinuous time series.) After running my macro, this same data looks like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 453"]
<tbody>[TR]
[TD]5/29/2014 18:19:11[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:12[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:13[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:14[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:15[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:16[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:17
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:18
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:19
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:20
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:21
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:22[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:23[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:24[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:25[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
This is working as intended.
Now here is the problem:
While running this macro on large data sets (100,000-750,000 lines) I encountered some large gaps in my data that this macro did NOT fill in with time stamps. To illustrate I've included an example below.
The example below shows gaps in time between the highlighted time stamps prior to running the macro to fill them in.
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 179"]
<tbody>[TR]
[TD]02/02/04 18:58:10[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:11[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:12[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:13[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:14[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:15[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:08[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:09[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:10[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:11[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:12[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:13[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:14[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:15[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 179"]
<tbody>[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]2[/TD]
[/TR]
[TR]
[TD]3[/TD]
[/TR]
[TR]
[TD]4[/TD]
[/TR]
[TR]
[TD]5[/TD]
[/TR]
[TR]
[TD]6[/TD]
[/TR]
[TR]
[TD]7[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
The example below shows some filled gaps in green but then there is a 7 minute gap between the last two red highlighted time stamps where the macro did not fill in missing time stamps.
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 179"]
<tbody>[TR]
[TD]02/02/04 18:58:11[/TD]
[TD="align: right"]436[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:12[/TD]
[TD="align: right"]436[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:13[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:14[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:15[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:16[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:17[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:19[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:20[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:21[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:22[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:23[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:24[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:25[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:26[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:27[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:28[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:29[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:30[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:31[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:32[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:33[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:34[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:35[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:36[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:37[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:38[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:39[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:40[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:41[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:42[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:43[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:44[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:45[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:46[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:47[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:48[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:49[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:50[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:51[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:52[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:53[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:54[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:55[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:56[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:57[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:58[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:59[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:01[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:02[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:03[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:04[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:05[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:06[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:07[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:08[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:09[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:10[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:11[/TD]
[TD="align: right"]436[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:12[/TD]
[TD="align: right"]436[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
Something interesting to note here: the time value 18:59:09 does not exist in the raw data, and so there should be no "6" next to it; the same goes for the time stamp 18:58:16, which should also not have a "5" next to it as it also doesn't exist in the raw data. These values next to the time stamps appear to be shifted from their original cells: "5" used to belong to 19:08:08 and "6" used to belong to 19:08:09. Also, 19:08:08 and 19:08:09 don't even exist in the data set after the macro has been run. So...we are quite lost at this point and any help would be greatly appreciated. I've included the macro below.
Sub addmissingseconds()
'This workbook has a very crude macro that inserts rows for missing seconds.
'The date and time must be in column A.
'The macro ignores the first 3 lines to allow for a header. We could make that two lines if better.
'The spreadsheet must have the date and time in column A.
'The macro will add the missing times in column A, and blank values in the other columns.
'With this macro open, you can open a spreadsheet of data and hit CTRL-SHIFT-I to insert the values.
'This spreadsheet should not be fully trusted. Check results and report back to Lonny.
Dim i As Long, x As Long
'step from end to the third row
For i = Range("a" & Rows.Count).End(xlUp).Row To 3 Step -1
x = Val(Format$(Cells(i, 1).Value - Cells(i - 1, 1).Value, "s"))
If x > 1 Then
Rows(i + 1).Resize(x - 1).Insert
With Cells(i, 1).Resize(x + 1)
.Formula = "=r[-1]c+""0:00:01"""
.Value = .Value
'this should add in the new row with just column A. Use Resize(, 3) for B and C
With .Offset(, 1).Resize(, 1)
'.Formula = "=r[-1]c"
'.Value = .Value
End With
End With
End If
Next
End Sub
Thank you very much for any help you might have to offer!
-Josiah
I am looking for some help either A) troubleshooting an existing macro or B) finding another (better?) method for solving the same problem.
Because my write-up has proven to be rather lengthy to explain, here is the "TLDR" version: I have a macro that is supposed to fill in gaps in a data set that has a time sequence. It has some strange bugs and isn't functioning properly. It is included at the bottom of the post. Any idea what is wrong? Should I be doing this a different way? Note: This problem has persisted between two computers, one using Windows 7 and Excel 2010, and another using Windows 7 and Excel 2013.
For those of you who are interested in the full explanation and everything I know so far, here goes:
I am working with large data sets (hundreds of thousands of lines+) that include a time stamp for each line. Each time stamp occurs after 1 second. Due to what I believe is hardware limitations with our data collectors, there is a missing value every so often (~90 line increments). To have a continuous time series I have been working with a macro that inserts a row for each missing time value and inserts the proper time stamp. Note: This problem has persisted between two computers, one using Windows 7 and Excel 2010, and another using Windows 7 and Excel 2013.
For example:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 453"]
<tbody>[TR]
[TD]5/29/2014 18:19:11[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:12[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:13[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:14[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:15[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:21[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:22[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:23[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:24[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:25[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
Between line 5 and line 6 there are 5 missing data points (and therefore a discontinuous time series.) After running my macro, this same data looks like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 453"]
<tbody>[TR]
[TD]5/29/2014 18:19:11[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:12[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:13[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:14[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:15[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:16[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:17
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:18
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:19
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:20
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:21
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:22[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:23[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:24[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]5/29/2014 18:19:25[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[TD]10[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
This is working as intended.
Now here is the problem:
While running this macro on large data sets (100,000-750,000 lines) I encountered some large gaps in my data that this macro did NOT fill in with time stamps. To illustrate I've included an example below.
The example below shows gaps in time between the highlighted time stamps prior to running the macro to fill them in.
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 179"]
<tbody>[TR]
[TD]02/02/04 18:58:10[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:11[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:12[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:13[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:14[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:15[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:08[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:09[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:10[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:11[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:12[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:13[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:14[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:15[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 179"]
<tbody>[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]2[/TD]
[/TR]
[TR]
[TD]3[/TD]
[/TR]
[TR]
[TD]4[/TD]
[/TR]
[TR]
[TD]5[/TD]
[/TR]
[TR]
[TD]6[/TD]
[/TR]
[TR]
[TD]7[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
[TR]
[TD]436[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
The example below shows some filled gaps in green but then there is a 7 minute gap between the last two red highlighted time stamps where the macro did not fill in missing time stamps.
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 179"]
<tbody>[TR]
[TD]02/02/04 18:58:11[/TD]
[TD="align: right"]436[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:12[/TD]
[TD="align: right"]436[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:13[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:14[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:15[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:16[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:17[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:19[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:20[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:21[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:22[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:23[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:24[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:25[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:26[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:27[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:28[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:29[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:30[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:31[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:32[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:33[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:34[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:35[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:36[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:37[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:38[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:39[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:40[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:41[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:42[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:43[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:44[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:45[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:46[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:47[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:48[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:49[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:50[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:51[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:52[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:53[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:54[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:55[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:56[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:57[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:58[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:58:59[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:01[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:02[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:03[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:04[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:05[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:06[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:07[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:08[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]02/02/04 18:59:09[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:10[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:11[/TD]
[TD="align: right"]436[/TD]
[/TR]
[TR]
[TD]02/02/04 19:08:12[/TD]
[TD="align: right"]436[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
Something interesting to note here: the time value 18:59:09 does not exist in the raw data, and so there should be no "6" next to it; the same goes for the time stamp 18:58:16, which should also not have a "5" next to it as it also doesn't exist in the raw data. These values next to the time stamps appear to be shifted from their original cells: "5" used to belong to 19:08:08 and "6" used to belong to 19:08:09. Also, 19:08:08 and 19:08:09 don't even exist in the data set after the macro has been run. So...we are quite lost at this point and any help would be greatly appreciated. I've included the macro below.
Sub addmissingseconds()
'This workbook has a very crude macro that inserts rows for missing seconds.
'The date and time must be in column A.
'The macro ignores the first 3 lines to allow for a header. We could make that two lines if better.
'The spreadsheet must have the date and time in column A.
'The macro will add the missing times in column A, and blank values in the other columns.
'With this macro open, you can open a spreadsheet of data and hit CTRL-SHIFT-I to insert the values.
'This spreadsheet should not be fully trusted. Check results and report back to Lonny.
Dim i As Long, x As Long
'step from end to the third row
For i = Range("a" & Rows.Count).End(xlUp).Row To 3 Step -1
x = Val(Format$(Cells(i, 1).Value - Cells(i - 1, 1).Value, "s"))
If x > 1 Then
Rows(i + 1).Resize(x - 1).Insert
With Cells(i, 1).Resize(x + 1)
.Formula = "=r[-1]c+""0:00:01"""
.Value = .Value
'this should add in the new row with just column A. Use Resize(, 3) for B and C
With .Offset(, 1).Resize(, 1)
'.Formula = "=r[-1]c"
'.Value = .Value
End With
End With
End If
Next
End Sub
Thank you very much for any help you might have to offer!
-Josiah