Private Sub Worksheet_Activate()
Dim tablo, ncol%, colmax%, i&, col%, j%
tablo = Sheets("BDD").[A1].CurrentRegion 'matrice, plus rapide
If Not IsArray(tablo) Then tablo = [A1:B1] 'sécurité si la feuille est vide
ncol = UBound(tablo, 2)
colmax = 1
For i = 2 To UBound(tablo)
col = 1
For j = 1 To ncol
If tablo(i, j) = 1 Then 'on s'appuie sur le chiffre 1
col = col + 1
tablo(i, col) = tablo(1, j)
If col > colmax Then colmax = col
End If
Next j
For j = col + 1 To ncol
tablo(i, j) = "" 'RAZ à droite
Next j, i
For j = 2 To colmax: tablo(1, j) = j - 1: Next j
'---restitution---
Application.ScreenUpdating = False
If FilterMode Then ShowAllData 'si la feuille est filtrée
UsedRange.EntireColumn.Delete 'RAZ
With [A1] '1ère cellule de restitution
.Resize(i - 1, colmax) = tablo
.CurrentRegion.Borders.Weight = xlThin 'bordures
End With
End Sub