• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Keywords separated by comma for Common/Similar Landing Pages

In the attached file there are two columns i.e. "Landing Pages" & "Keywords". I want a formula or maybe a way out for this one. Output required, there are similar "Landing Pages Link" in the first column which repeats for say 10 times and the Keywords against them is always different. Is there any way to get the data sorted in such a way that I get the Landing page link in the first column and in the next column all the keywords mapped to it separated by comma.

If possible kindly make the output file in that manner. Thanks a lot :)
 

Attachments

  • Unique_URLs_Multiple_Keywords.xlsx
    113.4 KB · Views: 13
Test this code on a backup. It will paste results in column C and D.

Code:
Public Sub CreateSummary()
Dim objDict As Object
Dim varInput, a, b
Dim i as Long
varInput = Range("A2:B" & Range("A" & Rows.Count).End(xlUp).Row).Value
Set objDict = CreateObject("Scripting.Dictionary")
objDict.comparemode = vbTextCompare

With objDict
    For i = LBound(varInput) To UBound(varInput)
        If .exists(varInput(i, 1)) Then
            .Item(varInput(i, 1)) = .Item(varInput(i, 1)) & ", " & varInput(i, 2)
        Else
            .Add varInput(i, 1), varInput(i, 2)
        End If
    Next
   
    a = .Keys: b = .Items
    For i = LBound(a) To UBound(a)
        Cells(i + 1, "C").Value = a(i)
        Cells(i + 1, "D").Value = b(i)
    Next i
End With
End Sub
 
Back
Top