Sub Worksheet_Activate()
Dim DL%, DC%, L%, C%, Col%
Application.ScreenUpdating = False
With Sheets("Feuil2")
DL = .[A10000].End(xlUp).Row
DC = .Cells(1, Columns.Count).End(xlToLeft).Column
[A2:Z1000].ClearContents
For L = 2 To DL
Col = 0: Cells(L, "A") = .Cells(L, "A")
For C = 2 To DC
If Left(.Cells(1, C), 7) = "DOMAINE" Then
If Col = 0 Then Col = 2 Else Col = Col + 3
Cells(L, Col) = .Cells(L, C)
Else
If Left(.Cells(1, C), 10) = "si domaine" Then
If .Cells(L, C) <> "" Then Cells(L, Col + 1) = Cells(L, Col + 1) & "," & .Cells(L, C)
If Left(Cells(L, Col + 1), 1) = "," Then Cells(L, Col + 1) = Mid(Cells(L, Col + 1), 2)
Else
If .Cells(L, C) <> "" Then Cells(L, Col + 2) = Cells(L, Col + 2) & "," & .Cells(L, C)
If Left(Cells(L, Col + 2), 1) = "," Then Cells(L, Col + 2) = Mid(Cells(L, Col + 2), 2)
End If
End If
Next C
Next L
End With
Columns.AutoFit: Rows.AutoFit
End Sub