Concatenate based on duplicate cells in different rows.

pjmthissen

New Member
Joined
Jan 10, 2018
Messages
4
Hi folks,

I have i list that shows in column A the title and in column B the topic.
This list is generated by an external system and unfortunately that system generates a new row in case a title has multiple topics.
I want generate list that has no duplicate titles and shows the topics concatenated in case a there are multiple topics per title.

In case I manage to get something like the below example I can use the remove duplicates functionality to get a list without duplicate titles.
Or is it possible to do both; concatenate the topic and remove a duplicate row in one go?

An example:
TitleTopicConcatenated topics
CRD / Light Production Business – REFRESHS&M - DSS&M - DS; S&M - BIS
CRD / Light Production Business – REFRESHS&M - BISS&M - DS; S&M - BIS
Purchase to Pay CurriculumS&M - DSS&M - DS
DS Managed Services Training PresalesS&M - DSS&M - DS
Negotiation and Closing of Business CasesS&M - DSS&M - DS; S&M - SB&S; S&M - IPS
Negotiation and Closing of Business CasesS&M - SB&SS&M - DS; S&M - SB&S; S&M - IPS
Negotiation and Closing of Business CasesS&M - IPSS&M - DS; S&M - SB&S; S&M - IPS
Advanced economics - deepen accounting fundamentalsS&M - DSS&M - DS; S&M - LFP
Advanced economics - deepen accounting fundamentalsS&M - LFPS&M - DS; S&M - LFP

<colgroup><col><col><col></colgroup><tbody>
</tbody>


Thanks in advance.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi & welcome to the board
How about
Code:
Sub ConcatCopy()

   Dim Cl As Range
   Dim Ws As Worksheet
   
   Set Ws = ActiveSheet
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws.Range("A2", Ws.Range("A" & Rows.Count).End(xlUp))
         If Not .exists(Cl.Value) Then
            .Add Cl.Value, Cl.Offset(, 1).Value
         Else
            .Item(Cl.Value) = .Item(Cl.Value) & "; " & Cl.Offset(, 1).Value
         End If
      Next Cl
      Sheets.Add(, Sheets(Sheets.Count)).Name = "New"
      Sheets("New").Range("A1").Value = "Title"
      Sheets("New").Range("B1").Value = "Concatenated topics"
      Sheets("New").Range("A2").Resize(.Count).Value = Application.Transpose(.keys)
      Sheets("New").Range("B2").Resize(.Count).Value = Application.Transpose(.items)
   End With
End Sub
 
Upvote 0
Unfortunately the code does not help me (it does not work in my spreadsheet). The only thing it does is creating a new worksheet named "New". Nothing is concatenated/copied to the new sheet.
 
Upvote 0
Was the sheet with your data the active sheet when you ran the macro?
Also is your data in cols A & B, starting with a header in row 1 & data in row 2?
 
Upvote 0
Yes it was the active sheet.
Also the sheet has headers in row 1.
Data starts in row 2 in column A and B.
 
Upvote 0
Glad to help & thanks for the feedback
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,077
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top