Try this code pasted into the tab for the output sheet (Sheet2 ?) in the VBA editor. It will regenerate the contents of the output sheet every time it is activated.
Private Sub Worksheet_Activate()
Cells.Clear
Sheets(1).Cells(1, 1).CurrentRegion.Copy Destination:=Cells(1, 1)
Cells(1, 1).CurrentRegion.Sort Header:=xlYes, Key1:=Cells(1, 1), Key1:=Cells(1, 4)
For N = Cells(Rows.Count, 1).End(xlUp).Row To 3 Step -1
If Cells(N, 1) = Cells(N - 1, 1) Then
Cells(N, 1).Clear
Cells(N, 4).Clear
End If
Next N
Columns(2).Insert
Columns(5).Copy Destination:=Columns(2)
Columns(5).Delete
Columns.AutoFit
For N = Cells(Rows.Count, 2).End(xlUp).Row To 3 Step -1
If Cells(N - 1, 2) <> "" Then
Rows(N).Insert
Range(Cells(N - 1, 3), Cells(N - 1, 5)).Cut Destination:=Range(Cells(N, 3), Cells(N, 5))
End If
Next N
For N = Cells(Rows.Count, 2).End(xlUp).Row To 3 Step -1
If Cells(N, 2) <> "" Then
Rows(N).Insert
End If
Next N
End Sub
Bookmarks