Merge list with several rows into new list with more columns

behedwin

Active Member
Joined
Dec 10, 2014
Messages
399
Hi
I have a list in excel with following columns

SocialID (unique number)
Name
Phone number

A person can have several rows since they can have 1 or 2 phone numbers.

I want to merge the list into a new with these columns.

SocialID
Name
Phonenumber 1
Phonenumber 2


How can i do this?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try this.
Your data starting in A2, the results in cell E2 onwards.

VBA Code:
Sub MergeList()
  Dim c As Range, f As Range
  Application.ScreenUpdating = False
  For Each c In Range("A2", Range("A" & Rows.Count).End(3))
    Set f = Range("E:E").Find(c.Value, , xlValues, xlWhole)
    If f Is Nothing Then
      Range("E" & Rows.Count).End(3)(2).Resize(1, 3).Value = Array(c, c.Offset(, 1), c.Offset(, 2))
    Else
      f.Offset(, 3).Value = c.Offset(, 2)
    End If
  Next
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,548
Members
449,170
Latest member
Gkiller

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