Private Sub Worksheet_Activate()
Dim F, dercol&, derlig&, n&, i&, k&, Id, nref&, nlig&, col
Application.ScreenUpdating = False: Set F = Worksheets("REDCAP")
If F.FilterMode Then F.ShowAllData
derlig = F.Cells(Rows.Count, "a").End(xlUp).Row
dercol = F.Cells(1, Columns.Count).End(xlToLeft).Column
ReDim ref(1 To derlig, 1 To 1)
Columns(1).Resize(, dercol).Clear
For i = 1 To derlig
Id = F.Cells(i, "a"): n = 0: col = "c"
For k = 1 To nref
If ref(k, 1) = Id Then n = k: Exit For
Next k
If n = 0 Then nref = nref + 1: ref(nref, 1) = Id: n = nref: nlig = nlig + 1: col = "a"
F.Cells(i, col).Resize(, dercol - IIf(col = "c", -2, 0)).Copy
Cells(n, col).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
Next i
Application.Goto Range("a1"), True
End Sub