Option Explicit
Sub testfusion()
Dim tableau(0 To 4), X, j&, j0&
tableau(0) = "O11"
tableau(1) = "O11"
tableau(2) = "O11"
tableau(3) = "O12"
tableau(4) = "O12"
Range(Cells(3, 1), Cells(3, UBound(tableau) + 1)).UnMerge
j0 = 0: j = j0
Do While j <= UBound(tableau)
X = tableau(j0)
Do While j <= UBound(tableau)
If tableau(j) <> X Then Exit Do
j = j + 1
Loop
j = j - 1
Cells(3, j0 + 1) = X
If j > j0 Then
Application.DisplayAlerts = False
Range(Cells(3, j0 + 1), Cells(3, j + 1)).Merge
Application.DisplayAlerts = True
End If
Range(Cells(3, j0 + 1), Cells(3, j + 1)).HorizontalAlignment = xlCenter
Range(Cells(3, j0 + 1), Cells(3, j + 1)).Borders.LineStyle = xlContinuous
j0 = j + 1: j = j0
Loop
End Sub