+ Reply to Thread
Results 1 to 6 of 6

Find and combine duplicate rows

  1. #1
    Forum Contributor
    Join Date
    06-12-2007
    Posts
    144

    Find and combine duplicate rows

    I need to find any rows where column A and B are the same,
    Put the total of the D column in one row and delete the other.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    See macro1 in attached file... I hope it's what you need.

    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-22-2003
    Posts
    9
    Hi,
    something like this could help.

    Jarek

    PHP Code: 
    Sub sum_qty()

    Application.ScreenUpdating False
    row_first 
    4
    row_last 
    Range("A" Rows.Count).End(xlUp).Row
    Range
    ("A" row_first ":D" row_last).Sort Key1:=Range("A4"), Order1:=xlAscending_
        Key2
    :=Range("B4"), Order2:=xlAscending

    For row_last To row_first 1 Step -1
        
    If Range("A" i).Value Range("A" 1).Value And Range("B" i).Value Range("B" 1).Value Then
            Range
    ("D" 1).Value Range("D" i).Value Range("D" 1).Value
            Rows
    (i).Delete
        End 
    If
    Next i

    Application
    .ScreenUpdating True

    End Sub 

  4. #4
    Forum Contributor
    Join Date
    06-12-2007
    Posts
    144
    I think Jarek's one is deleting too many rows.

    My stupid work computer wont let me download Antoka05's file but I will check it out when I get home.

    Thanks


    BTW this was my crude way of doing it (I had to run it several times):

    Please Login or Register  to view this content.
    Last edited by treva26; 09-07-2007 at 04:13 AM.

  5. #5
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    This is my macro (so you can try it) but please delete row3 if is empty:

    Please Login or Register  to view this content.
    Regards,
    Antonio

  6. #6
    Forum Contributor
    Join Date
    06-12-2007
    Posts
    144
    Cool, thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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