Results 1 to 4 of 4

Merge Duplicate data

Threaded View

  1. #1
    Registered User
    Join Date
    04-26-2009
    Location
    Los Angeles , California, USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Merge Duplicate data

    Im looking to save some time here.. I have over 10000 rows in excel which need to be merged

    i.e.
    MODEL,QTY
    1000,5
    2000,2
    3000,3
    2000,2

    and i want to run a macro to get this result
    1000,5
    2000,4
    3000,2

    I would like to remove duplicate model numbers but merge(add) the QTY field

    I did some research and came up with this macro.. but it only removed duplicate data... any help with a modification? or a better macro?

    Sub DelDups_OneList()
    Dim iListCount As Integer
    Dim iCtr As Integer
    
    ' Turn off screen updating to speed up macro.
    Application.ScreenUpdating = False
    
    ' Get count of records to search through.
    iListCount = Sheets("Sheet1").Range("A1:A100").Rows.Count
    Sheets("Sheet1").Range("A1").Select
    ' Loop until end of records.
    Do Until ActiveCell = ""
       ' Loop through records.
       For iCtr = 1 To iListCount
          ' Don't compare against yourself.
          ' To specify a different column, change 1 to the column number.
          If ActiveCell.Row <> Sheets("Sheet1").Cells(iCtr, 1).Row Then
             ' Do comparison of next record.
             If ActiveCell.Value = Sheets("Sheet1").Cells(iCtr, 1).Value Then
                ' If match is true then delete row.
                Sheets("Sheet1").Cells(iCtr, 1).Delete xlShiftUp
                   ' Increment counter to account for deleted row.
                   iCtr = iCtr + 1
             End If
          End If
       Next iCtr
       ' Go to next record.
       ActiveCell.Offset(1, 0).Select
    Loop
    Application.ScreenUpdating = True
    MsgBox "Done!"
    End Sub

    Thanks guys
    Last edited by VBA Noob; 04-26-2009 at 04:53 PM. Reason: Added code tags as per forum rules !

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