Range to be divided with dates

CESCOBAR

New Member
Joined
Jun 8, 2015
Messages
4
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?

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
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

C Moore

Well-known Member
Joined
Jan 17, 2014
Messages
544
Office Version
  1. 365
Platform
  1. Windows
Could you do helper columns, a first check in and last check in rank? Then use autofilter based on rank columns for the two helper columns to clear cells then resort range.
 

CESCOBAR

New Member
Joined
Jun 8, 2015
Messages
4
Could you do helper columns, a first check in and last check in rank? Then use autofilter based on rank columns for the two helper columns to clear cells then resort range.

Sorry, C Moore. I think I got lost right there at helper columns... and basically don't know how to do the rest... :confused::confused:
 

C Moore

Well-known Member
Joined
Jan 17, 2014
Messages
544
Office Version
  1. 365
Platform
  1. Windows
A helper column is one you add to a data set with a formula to 'help' find something. In this case, column K would be a formula to determine the rank per day of the check-in, and column L rank per day of 'check-out'.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,168
Messages
5,570,621
Members
412,333
Latest member
hectamuptra
Top