1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Sub FusionnerCel()
Dim Lig As Long, M, P As Long, Lig1 As Long
Dim DerLig As Long
Application.DisplayAlerts = False
Lig1 = 1 'Commencer à la ligne 1 à adapter
With Sheets("Feuil3") 'nom de la feuille à adapter
DerLig = Range("A65536").End(xlUp).Row
M = Cells(Lig1, 1): P = Lig1
For Lig = Lig1 To DerLig + 1
If Cells(Lig, 1) <> M Then
Range(Cells(P, 1), Cells(Lig - 1, 1)).Merge
M = Cells(Lig, 1): P = Lig
End If
Next Lig
With .Range(Cells(Lig1, 1), Cells(Lig - 1, 1))
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
End With
Application.DisplayAlerts = True
End Sub |
Partager