+ Reply to Thread
Results 1 to 3 of 3

Macro for deleting all rows, except first one and last one of every day

  1. #1
    Registered User
    Join Date
    10-31-2017
    Location
    Bucharest, Romania
    MS-Off Ver
    Excel 2016
    Posts
    2

    Macro for deleting all rows, except first one and last one of every day

    Hi guys,

    Not sure if it's nice to start straight away with a request, but If you guys can help I would appreciate.

    I need a macro that will delete all rows corresponding to Person1 ( or 2, or 3, etc ) except the first one and last one of each day.
    For example, in the table below, the first entry of Person1 in 10/3/2017 is at 03:37:31 and the last entry for that day at is 07:30:00. I need to delete all other rows between the first entry and last entry, for each day, based on the Person.



    Date Time Name
    10/3/2017 03:37:31 Person1
    10/3/2017 04:50:10 Person1
    10/3/2017 07:30:00 Person1
    10/4/2017 01:30:00 Person1
    10/4/2017 03:00:00 Person1
    10/4/2017 07:30:10 Person1
    10/3/2017 01:00:30 Person2
    10/3/2017 03:30:15 Person2
    10/3/2017 05:15:30 Person2
    10/4/2017 01:30:15 Person2
    10/4/2017 03:10:00 Person2
    10/4/2017 07:30:00 Person2


    Please help,
    Thank you

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,164

    Re: Macro for deleting all rows, except first one and last one of every day

    Hi Bender and welcome to the forum,

    Instead of VBA a Pivot Table might be faster or what you really need. See the attached that adds the Date and Time to a new column. Then use this column in a Pivot Table only showing the Min and Max per person.

    Pivot Table Min and Max Times per Person.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    10-31-2017
    Location
    Bucharest, Romania
    MS-Off Ver
    Excel 2016
    Posts
    2

    Re: Macro for deleting all rows, except first one and last one of every day

    Thank you, this helped

+ 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. Deleting Rows using VBA macro
    By TrueTears in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2013, 05:36 AM
  2. [SOLVED] Macro help with combining data across 2 rows (and deleting non-required rows)
    By InnesMcc in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 05-20-2013, 05:21 AM
  3. Macro for deleting rows
    By Galceran in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-28-2010, 02:42 PM
  4. How to make my macro delete rows? It currently hides the rows instead of deleting.
    By Majkataxmk in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-20-2010, 01:14 PM
  5. Macro for deleting rows
    By adamski in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2009, 08:25 AM
  6. macro for deleting rows
    By janjan_376 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-23-2009, 09:14 PM
  7. Deleting rows Macro
    By noxxero in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2007, 12:57 PM
  8. Macro for deleting rows
    By benxprezoise in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-30-2005, 06:40 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