Dim toto As Range
Application.DisplayAlerts = False ' pour ne pas avoir de message de confirmation
For i = 36 To 6 Step -1
If Range("B" & i - 1).Value = Range("B" & i).Value Then
If toto Is Nothing Then
Set toto = Application.Union(Range("B" & i - 1), Range("B" & i))
Else
Set toto = Application.Union(toto, Range("B" & i - 1))
End If
Else
If Not toto Is Nothing Then toto.Merge False
Set toto = Nothing
End If
Next
Application.DisplayAlerts = True ' pour rétablir les messages
Range("B6:B36").VerticalAlignment = xlCenter ' pour faire zouli
For i = 36 To 6 Step -1
If i = 36 Then toto = i
If Range("B" & i - 1).Value = Range("B" & i).Value Then
titi = i - 1
Else
If titi <> "" Then Range("B" & toto & ":B" & titi).Merge False
toto = i - 1: titi = ""
End If
Next
Application.DisplayAlerts = True ' pour rétablir les messages
Range("B6:B36").VerticalAlignment = xlCenter ' pour faire zouli
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question