+ Reply to Thread
Results 1 to 2 of 2

Merge Duplicate Rows unique values into single rows for an infinite amount of columns/rows

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    36

    Merge Duplicate Rows unique values into single rows for an infinite amount of columns/rows

    I have data with duplicate Part Numbers in an infinite amount of rows in column A, unique data in column B and duplicate data again in an infinite amount of columns (spreadsheet columns can vary so would like the range to be infinite).
    I need to merge all the duplicate Part Numbers into a single row and merge the column B values into a single cell delimited by a comma and then merge all the duplicate values for the rest of the columns.

    I found this macro that partially works. It identifies duplicate rows in A and merges the data in B and from columns D onwards but it deletes column C.

    Option Explicit

    Sub MergeGeneIDs()
    'Jerry Beaucaire, 2/6/2012
    'Merge rows matching on column A, opt to eliminate duplicates
    Dim LR As Long, Rw As Long, Delim As String

    If MsgBox("Eliminate duplicate values as they are merged?", _
    vbYesNo, "Duplicates") = vbYes Then [C1] = True

    Delim = Application.InputBox("What is the delimiter?", "Delimiter", ",", Type:=2)
    If Delim = "False" Then Exit Sub
    If Delim = "" Then Delim = ","

    Application.ScreenUpdating = False
    LR = Range("A" & Rows.Count).End(xlUp).Row

    Range("A:B").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlYes, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortTextAsNumbers

    With Range("C2:C" & LR)
    .Formula = "=IF(A2=A3,IF($C$1,IF(ISNUMBER(SEARCH(B2,C3)), C3, C3 & """ & _
    Delim & """ & B2), C3 & """ & Delim & """ & B2), B2)"
    .Value = .Value
    .Copy Range("B2")
    .Formula = "=A2=A1"
    End With

    Range("C:C").AutoFilter
    Range("C:C").AutoFilter 1, True
    Range("C2:C" & LR).EntireRow.Delete xlShiftUpMacro test.xls
    Range("C:C").AutoFilter
    Range("C:C").ClearContents
    Columns.AutoFit

    Application.ScreenUpdating = True
    End Sub


    how can i fix this? thanks

  2. #2
    Registered User
    Join Date
    08-21-2013
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: Merge Duplicate Rows unique values into single rows for an infinite amount of columns/

    not sure why my spreadsheet didnt attach the first time...Macro test.xls

+ 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. [SOLVED] Merge multiple duplicate rows into columns - more than 65536 rows
    By a3des in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-05-2013, 09:18 AM
  2. Replies: 6
    Last Post: 03-04-2013, 12:03 AM
  3. Replies: 5
    Last Post: 11-12-2012, 08:38 PM
  4. Conditional copy/merge rows with some duplicate, some unique lead cell value
    By atusing in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2012, 10:17 AM
  5. Merge duplicate rows and their columns
    By wali in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-17-2011, 06:35 AM

Tags for this Thread

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