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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,216,073
Messages
6,128,633
Members
449,460
Latest member
jgharbawi

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