Hi everyone,
I need a macro to parse a big data set. The data is logging every second, however I only require the values when it starts, then every 10 minutes after that. I process this file after its collected.
I want to start at the first time in R2C1, copy both the time and the Baro value. So copy R2C1 & R2C2 (both cells) for that time. Then paste these values into another worksheet. Then I need the next value 10 minutes later & repeat it for the entire file. So one continuous loop until all values are pasted into the one worksheet.
Time.........Baro
23:14:13 1022.7
23:14:14 1022.71
23:14:15 1022.67
23:14:16 1022.65
23:14:17 1022.63
23:14:18 1022.63
23:14:19 1022.64
23:14:20 1022.67
23:14:21 1022.69
23:14:22 1022.7
23:14:23 1022.66
23:14:24 1022.66
23:14:25 1022.65
23:14:26 1022.64
23:14:27 1022.65
23:14:28 1022.67
23:14:29 1022.71
23:14:30 1022.72
23:14:31 1022.7
23:14:32 1022.65
............ ...........
23:24:14 1022.60
............ ...........
Heres the code and the attachment I have so far. A loop may be easier.
The macro I recorded copied the first set of values and pasted it into a new sheet, then I added 10 minutes to the initial value in the cell below. Then I copied that new value and searched for it, then copied the correct set. I basically need a loop. This method I am using is not efficient.
Sub Macro4()
'
' Macro4 Recorded
Dim NewValue As String
NewValue = Selection.Value
'Paste Header Data and Initial Values to a New Sheet Called Parsed Data
Sheets("Import Data").Activate
Range("A1:B2").Select
Selection.Copy
Worksheets.Add(After:=Worksheets(1)).Name = "Parsed Data"
Range("A1:B2").Select
ActiveSheet.Paste
'Add 10 minutes
Range("A3").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+TIME(0,10,0)"
Range("A3").Select
Selection.Copy
'Go to Data and find the new time value i.e. 10 minutes later as copied from above line
Sheets("Import Data").Select
Range("A2").Select
Cells.Find(What:=NewValue, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False).Activate
'Found the time in the cell, now select this cell and the cell next to it.
ActiveCell.Resize(1, 2).Select
Application.CutCopyMode = False
Selection.Copy
'Paste it into the parsed data sheet
Sheets("Parsed Data").Select
ActiveSheet.Paste
Range("A4").Select
Application.CutCopyMode = False
'repeat
ActiveCell.FormulaR1C1 = "=R[-1]C+TIME(0,10,0)"
Range("A4").Select
Selection.Copy
Sheets("Import Data").Select
Range("A2").Select
Cells.Find(What:=NewValue, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False).Activate
ActiveCell.Resize(1, 2).Copy 'Range("A1202:B1202").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Parsed Data").Select
ActiveSheet.Paste
End Sub
Barometer Readings 2.xlsm
Bookmarks