Applying a conditional copy/paste based on Time/Date

ElPizz

New Member
Joined
Sep 17, 2015
Messages
1
Hi,

I've created a pivotchart/table containing values that have been recorded by 3 different PLCs. The CSV files contain the date and time for each value. My problem is that they all collect data at different time intervals. (One is every 5 mins, another is every 10 mins, and the last is insanely sporadic and has ~ 10% the number of values as the other 2). It was easy enough to line up the first two using the following VBA code which simply adds a blank row after every data pair:

Code:
 Sub Insert_Blank_Rows()

         'Select last row in worksheet.
         Selection.End(xlDown).Select

         Do Until ActiveCell.Row = 1
            'Insert blank row.
            ActiveCell.EntireRow.Insert shift:=xlDown
            'Move up one row.
            ActiveCell.Offset(-1, 0).Select
         Loop

      End Sub

The tricky part is getting the 3rd set of values to line up correctly with the first 2. The data seems to be collected at random intervals, (sometimes 15mins apart others 4-5 hours) so there's no set pattern for me to divide the data up. I can manually go in and add rows until the data points line up, but as we all know, there's always a macro/VBA solution. The date/time is stored in the excel decimal format so I'm thinking there's some sort of conditional copy paste I can do based on a subtraction of the date/time? It would be parsing through the compiled data file column (We''ll call it column A) for the date/time, and would only paste the data value from the PLC_3 data file if the date value for each was within a certain range (x amount of sec or min) Any help would be appreciated and I'm open to completely going back to the drawing board too.

[table="width: 500"]
[tr]
[td]PLC1 Time[/td]
[td]PLC1 value[/td]
[td]PLC2 Time[/td]
[td]PLC2 value[/td]
[td]PLC3 Time[/td]
[td]PLC3 value[/td]
[/tr]
[tr]
[td]10:00[/td]
[td]21[/td]
[td]10:05[/td]
[td]19[/td]
[td]10:17[/td]
[td]22[/td]
[/tr]
[tr]
[td]10:10[/td]
[td]22[/td]
[td]10:10[/td]
[td]19[/td]
[td]11:38[/td]
[td]20[/td]
[/tr]
[tr]
[td]10:20[/td]
[td]18[/td]
[td]10:15[/td]
[td]22[/td]
[td]2:19[/td]
[td]20[/td]
[/tr]
[tr]
[td]10:30[/td]
[td]19[/td]
[td]10:20[/td]
[td]17[/td]
[td]14:22[/td]
[td]20[/td]
[/tr]
[tr]
[td]10:40[/td]
[td]22[/td]
[td]10:25[/td]
[td]21[/td]
[td]14:25[/td]
[td]21[/td]
[/tr]
[tr]
[td]10:50[/td]
[td]23[/td]
[td]10:30[/td]
[td]20[/td]
[td]21:07[/td]
[td]19[/td]
[/tr]
[tr]
[td]11:00[/td]
[td]22[/td]
[td]10:35[/td]
[td]22[/td]
[td]23:16[/td]
[td]22[/td]
[/tr]
[/table]

I hope this table helps describe my issue, thanks for any help!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top