+ Reply to Thread
Results 1 to 2 of 2

Stuck on a tough one (for me!)

Hybrid View

  1. #1
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    Stuck on a tough one (for me!)

    Hello all,

    I'm trying to find a macro or function that will recognize duplicates in column A, and combine column Bs results next to column A (with each result in next column). For example, here's what my columns look like:

    200604200214 ECO Folder is complete
    200604200214 690206366
    200604200214 TID missing
    200607270050 690206412
    200607270050 TID missing
    200608160137 690200160
    200608160137 ECO Folder is complete
    200608170103 ECO Folder is complete
    200608170103 690206341
    200608170103 TID missing
    200608210052 690103335
    200608210052 ECO Folder is complete

    Here's what I wish the result was:
    200604200214 690206366 TID missing ECO Folder is complete
    200607270050 690206412 TID missing ECO Folder is complete
    200608160137 690200160 ECO Folder is complete
    200608170103 690206341 TID missing ECO Folder is complete
    200608210052 690103335 ECO Folder is complete

    Thanks for any assistance !

    Oreg

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Try this macro
    It assumes data is already sorted by column a
    it runs from last row to 1st row
    when duplicate entries found in column A the entry in column B is merged with the entry in column B in the row above it and the lower row is deleted

    Sub MergDuplicates()
    Dim l4Row As Integer
    Dim lRow As Long


    Application.ScreenUpdating = False

    For l4Row = Cells(Rows.Count, "a").End(xlUp).Row _
    To 2 Step -1

    'compare data in 2 rows
    If Cells(l4Row, "a").Value = _
    Cells(l4Row - 1, "a").Value Then

    ' merge column b data
    Cells(l4Row - 1, "b").Value = _
    Cells(l4Row - 1, "b").Value _
    & " " & Cells(l4Row, "b").Value

    'delete row merged to row above
    Rows(l4Row).Delete Shift:=xlUp
    End If

    Next l4Row

    Application.ScreenUpdating = True
    End Sub

+ 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