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
 

C Moore

Active Member
Joined
Jan 17, 2014
Messages
431
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

Active Member
Joined
Jan 17, 2014
Messages
431
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'.
 

Forum statistics

Threads
1,082,119
Messages
5,363,272
Members
400,724
Latest member
Angeljurich15

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top