Hey everyone,
I have a range from D14 to j200 (will vary each month) with information regarding employees' productive time. This information has dates and check-in information at each door.
I need to delete the first check in of the day at the entrance and the last check in of the day at the exit for each productive day in april. Entrance info (date, name of the door, time of check-in at that door, time outside of production) is found from columns G to J. Exit info (date, access point, and time) is from columns D to F.
I've been filtering by day and using offset command to move to and delete the first entrance of the day and then moving with .End(x1to right, left or down) to delete the last exit of the day.
Heres the sample code I have. Can you help me optimize it?
I've only managed to do the proper deletion of data for the first day only... when filtering for the next work day I get stuck
I have a range from D14 to j200 (will vary each month) with information regarding employees' productive time. This information has dates and check-in information at each door.
I need to delete the first check in of the day at the entrance and the last check in of the day at the exit for each productive day in april. Entrance info (date, name of the door, time of check-in at that door, time outside of production) is found from columns G to J. Exit info (date, access point, and time) is from columns D to F.
I've been filtering by day and using offset command to move to and delete the first entrance of the day and then moving with .End(x1to right, left or down) to delete the last exit of the day.
Heres the sample code I have. Can you help me optimize it?
Code:
Range("$D$14:$J$14").Select
Selection.AutoFilter
ActiveSheet.Range("$D$14:$J$800").AutoFilter Field:=4, Criteria1:=Array("=" _
), Operator:=xlFilterValues, Criteria2:=Array(2, "4/1/2015")
Range("$G$14:$J$14").Select
Do
Selection.Offset(1, 0).Select
Loop While Selection.EntireRow.Hidden = True
Selection.ClearContents
Range("$D$14:$F$14").Select
Selection.End(xlDown).Select
ActiveCell.Resize(1, 3).Select
Selection.ClearContents
Range("$G$14:$J$14").Select
Do
Selection.Offset(2, 0).Select
Loop While Selection.EntireRow.Hidden = True
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("$G$14").Select
Do
Selection.Offset(1, 0).Select
Loop While Selection.EntireRow.Hidden = True
ActiveSheet.Paste
Range("$D$14:$F$14").Select
Do
Selection.Offset(1, 0).Select
Loop While Selection.EntireRow.Hidden = True
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("$D$14").Select
Do
Selection.Offset(1, 0).Select
Loop While Selection.EntireRow.Hidden = True
ActiveSheet.Paste
ActiveSheet.ShowAllData
Range("$D$14:$J$14").Select
I've only managed to do the proper deletion of data for the first day only... when filtering for the next work day I get stuck