Sub Demo2()
Dim L&, C, Y, H, A%, F%, N%, S$, R&
Me.UsedRange.Clear
Application.ScreenUpdating = False
L = 1
With Worksheets("ORIGINAL").[A1].CurrentRegion
C = Application.Match("FIN_BUY_FOR_NAME", .Rows(1), 0)
Y = Application.Match("YEAR", .Rows(1), 0)
If IsError(C) Or IsError(Y) Then Beep: Exit Sub
.Columns(Y).AdvancedFilter xlFilterCopy, , [B1], True
With Range("B2", [B1].End(xlDown))
.Sort .Cells(1), xlAscending, Header:=xlNo
H = Application.Transpose(.Value)
End With
A = Y + 1
F = Y - 1
N = .Columns.Count - Y
S = Cells(A).Resize(, N).Address
.Cells(1).Resize(, F).Copy [A1]
For R = 1 To UBound(H)
Cells(Y - N + R * N).Resize(, N).Value = .Parent.Evaluate(H(R) & "&"" ""&" & S)
Next
For R = 2 To .Rows.Count
If .Cells(R, C).Value <> .Cells(R - 1, C).Value Then
L = L + 1
Cells(L, 1).Resize(, F).Value = .Cells(R, 1).Resize(, F).Value
End If
Cells(L, Y + (.Cells(R, Y).Value - H(1)) * N).Resize(, N).Value = .Cells(R, A).Resize(, N).Value
Next
End With
Application.ScreenUpdating = True
End Sub