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.

PLC1 TimePLC1 valuePLC2 TimePLC2 valuePLC3 TimePLC3 value
10:002110:051910:1722
10:102210:101911:3820
10:201810:15222:1920
10:301910:201714:2220
10:402210:252114:2521
10:502310:302021:0719
11:002210:352223:1622

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

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,375
Messages
6,124,591
Members
449,174
Latest member
chandan4057

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