+ Reply to Thread
Results 1 to 11 of 11

How to get the filter rows to always get the first and last row in a daterange

  1. #1
    Registered User
    Join Date
    05-23-2007
    Posts
    10

    How to get the filter rows to always get the first and last row in a daterange

    Hi Forum

    I'm trying to build a report whereby i collate the first punch in and the last punch out from a set of data. any help please?

    This is a sample data:
    02-May-14 09:00
    02-May-14 19:14
    05-May-14 09:31
    05-May-14 19:38
    06-May-14 09:31
    06-May-14 12:56
    06-May-14 13:10
    06-May-14 20:11
    07-May-14 08:36
    07-May-14 12:45
    08-May-14 08:45
    08-May-14 12:35
    08-May-14 13:23
    08-May-14 19:54


    My result should be the following:
    02-May-14 09:00
    02-May-14 19:14
    05-May-14 09:31
    05-May-14 19:38
    06-May-14 09:31
    ***these cells should be filtered out
    06-May-14 20:11
    07-May-14 08:36
    07-May-14 12:45
    08-May-14 08:45
    ***these cells should be filtered out
    08-May-14 19:54

    Thank you in advance for your assistance

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to get the filter rows to always get the first and last row in a daterange

    Is the date and time in the same cell?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    05-23-2007
    Posts
    10

    Re: How to get the filter rows to always get the first and last row in a daterange

    Hi Tony

    Thanks for your reply. I can have them in the same cell or seperate....right now they are seperate.

    Thanks

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to get the filter rows to always get the first and last row in a daterange

    Here's one way to do it...

    Data Range
    A
    B
    C
    D
    E
    F
    1
    Date
    In/Out
    ------
    Date
    In
    Out
    2
    2-May-14
    9:00
    2-May-14
    9:00
    19:14
    3
    2-May-14
    19:14
    5-May-14
    9:31
    19:38
    4
    5-May-14
    9:31
    6-May-14
    9:31
    20:11
    5
    5-May-14
    19:38
    7-May-14
    8:36
    12:45
    6
    6-May-14
    9:31
    8-May-14
    8:45
    19:54
    7
    6-May-14
    12:56
    8
    6-May-14
    13:10
    9
    6-May-14
    20:11
    10
    7-May-14
    8:36
    11
    7-May-14
    12:45
    12
    8-May-14
    8:45
    13
    8-May-14
    12:35
    14
    8-May-14
    13:23
    15
    8-May-14
    19:54


    You can use advanced filter to extract the unique dates and copy them to another location (like column D in the example).

    Then, you can use these array formulas** to get the In and Out times for each date.

    This array formula** entered in E2:

    =MIN(IF(A$2:A$15=D2,B$2:B$15))

    This array formula** entered in F2:

    =MAX(IF(A$2:A$15=D2,B$2:B$15))

    Format E2:F2 as time h:mm then copy down as needed.

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  5. #5
    Registered User
    Join Date
    05-23-2007
    Posts
    10

    Re: How to get the filter rows to always get the first and last row in a daterange

    Tony, thanks a million. This worked for one employee. Now can I ask another question please?

    My Excel sheet has a number of employees and I would like to have the same result for all of them. Anyway I can do it?

    Sample
    sample.xlsx

  6. #6
    Registered User
    Join Date
    05-23-2007
    Posts
    10

    Re: How to get the filter rows to always get the first and last row in a daterange

    Tony....i found a work around....i concatenated the first columns - therefore having a unique identifier and it worked....thanks so much for your support.

    If there are other ways on how to go about it, I would still like to know increase my knowledge at least

    Ad

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to get the filter rows to always get the first and last row in a daterange

    Looks like you have a lot of data.

    If you're happy with your current solution then by all means continue to use it.

    Another possibility would be to use a pivot table. Unfortunately, I never use pivot tables so I can't tell you how to set it up.

    Let me see if I can get the attention of someone that is good with pivot tables.

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to get the filter rows to always get the first and last row in a daterange

    Or with an pivot table.

    See the attached file.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  9. #9
    Registered User
    Join Date
    05-23-2007
    Posts
    10

    Re: How to get the filter rows to always get the first and last row in a daterange

    Thanks a million to both

  10. #10
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to get the filter rows to always get the first and last row in a daterange

    Thanks for the reply.

    Glad I could help.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How to get the filter rows to always get the first and last row in a daterange

    You're welcome!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Delete Rows hidden by either Auto Filter and Advanced Filter
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 10:29 AM
  2. sumif with multiple criteria (including daterange)
    By TPS Tom in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-28-2011, 07:43 AM
  3. Sum values on specific date within a daterange (multiple ranges)
    By Fredrik S in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-26-2008, 05:47 AM
  4. Want to create a forumla on daterange
    By buntyindia in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-15-2007, 04:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1