Private Sub Worksheet_Activate()
Dim L%, a, ub%, ncol%, base, lig&, d As Object, i&, num, nlig&
Dim j%, nlig1&, rest(), t, n&, p&, q%, coul&
L = 4 'nombre de colonnes dans chaque feuille, à adapter
a = Array("Base", "Momo", "Lolo", "May") 'feuilles à étudier
ub = UBound(a)
ncol = (L - 1) * ub + L
base = Sheets(a(0)).[A1].CurrentRegion.Resize(, L)
lig = 3 '1ère ligne à renseigner
Set d = CreateObject("Scripting.Dictionary")
Application.ScreenUpdating = False
Rows("3:" & Rows.Count).Delete 'RAZ
For i = 2 To UBound(base)
num = base(i, 1)
If Not d.exists(num) Then 'élimine les doublons
d(num) = ""
nlig = 0
For j = 1 To ub
nlig1 = Application.CountIf(Sheets(a(j)).[A:A], num)
If nlig1 > nlig Then nlig = nlig1
Next j
If nlig Then
nlig1 = Application.CountIf(Sheets(a(0)).[A:A], num)
If nlig1 > nlig Then nlig = nlig1
ReDim rest(1 To nlig, 1 To ncol)
rest(1, 1) = num
For j = 0 To ub
t = Sheets(a(j)).[A1].CurrentRegion.Resize(, L)
n = 0
For p = 2 To UBound(t)
If t(p, 1) = num Then
n = n + 1
For q = 2 To L
rest(n, j * (L - 1) + q) = t(p, q)
Next q
End If
Next p
Next j
coul = coul + 1
With Cells(lig, 2).Resize(nlig, ncol)
.Value = rest
.Columns(1).Merge 'fusionne les cellules
If coul Mod 2 Then .Interior.ColorIndex = 24
End With
lig = lig + nlig
End If
End If
Next i
'---bordures---
If lig = 3 Then Exit Sub
For j = 7 To 12
[B3].Resize(lig - 3, ncol).Borders(j).Weight = xlThin
Next j
End Sub