+ Reply to Thread
Results 1 to 5 of 5

Remove Duplicate Rows within Specified Time Range

  1. #1
    Registered User
    Join Date
    08-24-2020
    Location
    Manchester, England
    MS-Off Ver
    O365
    Posts
    62

    Remove Duplicate Rows within Specified Time Range

    Hi guys,

    After you massive help last time I thought I'd run this one by you!

    I'm trying to use VBA to remove duplicate rows from a table. say there were two rows with a duplicate value in column C, I would like to keep one of the two. I would also like to be able to set a time range for when to remove the duplicates. For instance, I want to remove the duplicate row containing value 101 in column C from the attached spreadsheet, I want the first one of the two values to remain, but I would like the two entries of 101 20 minutes later to also show only one of these values.

    Sorry if that makes no sense or if it can't be done! It's the higlighted yellow rows I'm trying to keep, so only to remove duplicate rows based on values in column C, and only duplicates found within 20 minutes
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    According to your attachment as a VBA beginner starter :

    PHP Code: 
    Sub Demo1()
                Const 
    4
                  Dim D
    %(), VR&, T#, N&
        
    With [A1].CurrentRegion.Rows
                ReDim D
    (1 To .Count0)
                
    = .Value2
            
    For 1 To .Count 1
                
    If D(R0) = 0 Then
                        T 
    V(R1) + #12:20:00 AM#
                    
    For 1 To .Count
                        
    If V(N3) <> V(R3Then Exit For
                        If 
    V(N1) > T Then Exit For Else D(N0) = 1
                    Next
                End 
    If
            
    Next
               R 
    Application.Sum(D) - 1
            
    If > -1 Then
                Application
    .ScreenUpdating False
               
    .Columns(C) = D
               
    .Resize(, C).Sort .Columns(C), xlAscendingHeader:=xlNo
                Union
    (.Item(.Count ":" & .Count), .Columns(C)).Clear
                Application
    .ScreenUpdating True
            End 
    If
        
    End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  3. #3
    Registered User
    Join Date
    08-24-2020
    Location
    Manchester, England
    MS-Off Ver
    O365
    Posts
    62

    Re: Remove Duplicate Rows within Specified Time Range

    Amazing, thank you!

    Would I be right in assuming if I wanted to edit the time range from 20 minutes to 10 minutes I would edit this line to show 12:10:00 rather than 12:20:00?
    T = V(R, 1) + #12:20:00 AM#

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Remove Duplicate Rows within Specified Time Range


    Exactly …


    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  5. #5
    Registered User
    Join Date
    08-24-2020
    Location
    Manchester, England
    MS-Off Ver
    O365
    Posts
    62

    Re: Remove Duplicate Rows within Specified Time Range

    Apologies for the delay!

    And thank you for pointing that out, I have done as you mentioned!

    Would it be terrible if you could give me a breakdown of the code you created? VBA is very new to me so I'm trying to learn it, but now I have a workbook that I use I will hopefully be able to understand line by line this code!

+ 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. remove duplicate rows
    By max_max in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2015, 04:33 PM
  2. [SOLVED] How to sum duplicate values then remove the duplicate rows?
    By terry3218 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-12-2015, 02:38 AM
  3. Replies: 1
    Last Post: 12-11-2013, 09:09 PM
  4. [SOLVED] Remove Duplicate rows
    By andyking40 in forum Excel General
    Replies: 6
    Last Post: 04-28-2013, 12:09 PM
  5. excel macro to remove specific columns and rows + remove duplicate
    By garrywelson in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-17-2013, 12:03 PM
  6. Excel 2007 : Remove duplicate rows
    By springprogressive in forum Excel General
    Replies: 1
    Last Post: 09-05-2011, 07:32 AM
  7. remove duplicate rows
    By shahcu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2008, 05:04 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