Data is being pulled from SHEET1 and transposed and joined on SHEET2.
Problem: Sheet1's column "E" is supposed to be at the top header row on SHEET2, but it is not working.
Problem: Sheet1's column "E" is supposed to be at the top header row on SHEET2, but it is not working.
VBA Code:
Sub ReArrange()
Dim a As Variant, b As Variant, cr As Variant
Dim d As Object
Dim i As Long, lr As Long
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = 1
With Sheets("Sheet1")
lr = .Range("B" & Rows.Count).End(xlUp).Row
a = Application.Index(.Cells, Evaluate("row(2:" & lr & ")"), Array(1, 5, 3, 2))
End With
ReDim b(1 To UBound(a), 1 To UBound(a))
For i = 1 To UBound(a)
If Not d.exists(a(i, 3)) Then d(a(i, 3)) = d.Count + 1 & " 1"
cr = Split(d(a(i, 3)))
b(cr(1), cr(0)) = Join(Application.Index(a, i, Array(1, 2, 3, 4)), vbLf)
d(a(i, 3)) = cr(0) & " " & cr(1) + 1
Next i
With Sheets("Sheet2")
With .Range("A2").Resize(UBound(a), d.Count)
.WrapText = True
.Value = b
.Rows(0).Value = d.Keys
End With
End With
End Sub