Pivoting repeated strings

camchocho

New Member
Joined
Nov 9, 2017
Messages
1
Sorry if the title isn't descriptive I honestly had no clue how to quickly say what I'm working on.Hello, thanks very much in advanced for the help. Basically I have a long list with two columns, the first column has a word and the second a string of numbers. I would like to automatically re-arrange it so that any time something from column A is repeated it is removed but it's number string from column B is added to a new column next to the first time the word popped up in column A. Note that I want exact matches only, since there are very similiar word strings in some of column A.

Here is an example; the top is what my data looks like now, and the bottom is what I would like to be able to do with it. I had thought of doing a conditional formatting for repeats and then a pivot-paste kind of thing, but there's about 10000 strings in my sheet so automation would be very helpful.


<tbody>
[TD="align: left"]AA[/TD]
[TD="align: right"]123[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA[/TD]
[TD="align: right"]124[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA[/TD]
[TD="align: right"]125[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA[/TD]
[TD="align: right"]126[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA2[/TD]
[TD="align: right"]127[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA2[/TD]
[TD="align: right"]128[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA3[/TD]
[TD="align: right"]129[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA3[/TD]
[TD="align: right"]130[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]BB[/TD]
[TD="align: right"]131[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]BB[/TD]
[TD="align: right"]132[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]BB[/TD]
[TD="align: right"]133[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]BC[/TD]
[TD="align: right"]134[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]BC[/TD]
[TD="align: right"]135[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]BC[/TD]
[TD="align: right"]136[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]BE[/TD]
[TD="align: right"]137[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA[/TD]
[TD="align: right"]123[/TD]
[TD="align: right"]124[/TD]
[TD="align: right"]125[/TD]
[TD="align: right"]126[/TD]

[TD="align: left"]AA2[/TD]
[TD="align: right"]127[/TD]
[TD="align: right"]128[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]AA3[/TD]
[TD="align: right"]129[/TD]
[TD="align: right"]130[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

[TD="align: left"]BB[/TD]
[TD="align: right"]131[/TD]
[TD="align: right"]132[/TD]
[TD="align: right"]133[/TD]
[TD="align: left"][/TD]

[TD="align: left"]BC[/TD]
[TD="align: right"]134[/TD]
[TD="align: right"]135[/TD]
[TD="align: right"]136[/TD]
[TD="align: left"][/TD]

[TD="align: left"]BE[/TD]
[TD="align: right"]137[/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]
[TD="align: left"][/TD]

</tbody>
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hello,

from myarchiv w/o adaption.

Code:
Sub iFen()
Ar = Cells(1).CurrentRegion
With CreateObject("scripting.dictionary")
    For i = 2 To UBound(Ar)
        If .exists(Ar(i, 1)) Then
            .Item(Ar(i, 1)) = .Item(Ar(i, 1)) & ", " & Ar(i, 2)
        Else
            .Item(Ar(i, 1)) = Ar(i, 2) 
        End If
    Next i

Cells(5, 1).Resize(.Count, 2) = Application.Transpose(Array(.keys, .items))
End With
End Sub

I hope you can debug it.

regards
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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