Data to another worsheet in excel based on...

[Closed]
Report
Posts
1
Registration date
Tuesday July 24, 2012
Status
Member
Last seen
July 24, 2012
-
Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
-
Hello,

I have got an excel file where I have collected datas each second.
I would like to copy rows of data to another worksheet based on the time column with 10 seconds increment.
Means I want data at 10:50:10, then data at 10:50:20.......etc
Can someone help me with the script.
Thanks





1 reply

Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
486
Hi Jessen,

Assuming that the times are in Column A and that the first row is used as header.
Your destination sheet is referred to as Sheet2 in the code.

Adjust the following code to match your situation:
Sub MoveData()
Dim lRow, lRow2 As Integer
Dim cValue As Date
lRow = Range("A" & Rows.Count).End(xlUp).Row
For Each cell In Range("A2:A" & lRow)
cValue = cell.Value
If Right(cValue, 1) = 0 Then
lRow2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Row
cell.EntireRow.Copy Sheets("Sheet2").Range("A" & lRow2)
End If
Next
End Sub

Best regards,
Trowa