Salut,
En effet, c'était pas bête comme idée !
Alors :
- première code, sa insère des lignes lorsque H et H+1 <>
Sub i1() 'Insérer lignes si matière <>
Dim c As Long
Dim LastRow As Long
LastRow = Cells(Rows.Count, "H").End(xlUp).Row
For c = LastRow To 12 Step -1
If Range("H" & c).Value <> Range("H" & c).Offset(-1, 0).Value Then
Range("H" & c).EntireRow.Insert shift:=xlDown
End If
Next
End Sub
- second code, sa supprime et additionne les doublons
Sub i2()
Dim dlig&, lig&: Application.ScreenUpdating = 0
dlig = Cells(Rows.Count, 4).End(xlUp).Row
For lig = dlig To 12 Step -1
With Cells(lig, 4)
If .Value <> "" And .Value = .Offset(-1) Then
.Offset(-1, 1) = .Offset(-1, 1) + .Offset(, 1)
Rows(lig).Delete
End If
End With
Next lig
End Sub
Étrangement, sa marche bien si je fait un bouton pour appeler le premier code, et un autre bouton pour le second.
Sauf que je fais sa avec un seul bouton, en faisant :
Public Sub CommandButton1_Click()
Call i1
Call i2
End Sub
Et on trouve le résultat avec des lignes vides en haut..
Cordialement