Option Explicit
Sub MergeData()
' hiker95, 01/27/2011
' http://www.mrexcel.com/forum/showthread.php?t=524184
Dim w1 As Worksheet, w2 As Worksheet
Dim LR As Long, LC As Long, a As Long, b As Long, NR As Long, SR As Long, ER As Long, NC As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
Set w2 = Worksheets("Sheet2")
LR = w1.Cells(Rows.Count, 1).End(xlUp).Row
LC = w1.Cells.Find("*", , xlValues, xlWhole, xlByColumns, xlPrevious, False).Column
w1.Range(w1.Cells(2, 1), w1.Cells(LR, LC)).Sort Key1:=w1.Range("A2"), Order1:=xlAscending, Key2:=w1.Range("B2") _
, Order2:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
w1.Range("A1").EntireColumn.Insert
w1.Columns("B:B").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=w1.Columns("A:A"), Unique:=True
LR = w1.Cells(Rows.Count, 1).End(xlUp).Row
NR = w2.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
w1.Range("A2:A" & LR).Copy w2.Range("A" & NR)
w1.Range("A1").EntireColumn.Delete
LR = w2.Cells(Rows.Count, 1).End(xlUp).Row
For a = 2 To LR Step 1
SR = Application.Match(w2.Range("A" & a).Value, w1.Columns(1), 0)
ER = Application.Match(w2.Range("A" & a).Value, w1.Columns(1), 1)
w1.Range("B" & SR & ":AC" & SR).Copy w2.Range("B" & NR)
NC = 30
For b = SR + 1 To ER Step 1
w2.Cells(a, NC).Value = w1.Cells(b, 2).Value
w2.Cells(a, NC + 1).Resize(, 16).Value = w1.Range("J" & b & ":Y" & b).Value
NC = NC + 17
Next b
Next a
w2.Activate
Application.ScreenUpdating = True
End Sub