Merging duplicate fields

felipelisboam

New Member
Joined
Jul 18, 2016
Messages
1
Hello.

Im having trouble merging duplicate fields with same First and Last name. My spreadsheet looks like this:

FIRST_NAMELAST_NAMEYEAR
JohnJones2013
JohnJones2012
JohnJones2011
JohnJones2009
JohnJones2008

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

I basically need to combine it all under one row to look like this:

FIRST_NAMELAST_NAMEYEAR
JohnJones2008, 2009, 2011, 2012, 2013

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


Can someone please help? Been struggling with this for a while.

Thanks a lot!
Felipe
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Sub macro1()
Dim lngLastRow As String
Dim lastRow As Long
Dim lastcolumn As Long
Application.ScreenUpdating = False

lastRow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
lastcolumn = ActiveSheet.UsedRange.Column - 1 + ActiveSheet.UsedRange.Columns.Count

ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add Key:=Range(Cells(2, 1), Cells(lastRow, 1)), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveSheet.Sort.SortFields.Add Key:=Range(Cells(2, 2), Cells(lastRow, 2)), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

With ActiveSheet.Sort
.SetRange Range(Cells(1, 1), Cells(lastRow, lastcolumn))
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

For i = lastRow To 2 Step -1

If Cells(i, 1).Value = Cells(i - 1, 1).Value And Cells(i, 2).Value = Cells(i - 1, 2).Value Then
Cells(i - 1, 3).Value = Cells(i - 1, 3).Value & " , " & Cells(i, 3).Value
Rows(i).EntireRow.Delete
End If

Next
Application.ScreenUpdating = True

End Sub
 
Upvote 0
Can you use something like this? The first two formulas selects for unique items. The formula for years for years curiously requires the &" " to allow for spaces. However, I did the same for a text sample. if you enter for example enter a (plus space), then enter. Then the same for b to do. This same formula will show spaces between letters. For the year formula, you need to enter the formula. Then use your mouse to highlight the transpose part of the formula. Select F9.This will show {"a","b"......}. You need to remove both {'s. Then press enter. The original formula is =concatenate(transpose(range)). Use F9 select to transpose part .it looks like the transpose part of the formula disappears, leaving only =concatenate

Excel 2012
ABCD
1First NameLast NameYear
2JohnJones2013a
3JohnJones2012b
4JohnJones2011c
5JohnJones2009d
6JohnJones2008e
7
8First NameLast NameYear
9JohnJones2013 2012 2011 2009 2008 a b c d e

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
C9=CONCATENATE(2013&" ",2012&" ",2011&" ",2009&" ",2008&" ")
D9=CONCATENATE("a ","b ","c ","d ","e ")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
A9{=INDEX($A$2:$A$6,MATCH(0,COUNTIF(A$8:A8,A$2:A$6),0))}
B9{=INDEX($B$2:$B$6,MATCH(0,COUNTIF(B$8:B8,B$2:B$6),0))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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