Sub Macro1()
Dim plage As Range, plage_a_supp As Range
Dim nb As Integer
Dim j As Integer
Cells(1, 1) = "0"
Cells(2, 1) = "0"
Cells(3, 1) = "0"
Cells(4, 1) = "0"
Cells(5, 1) = "0"
Cells(6, 1) = "0"
Cells(7, 1) = "0"
Cells(8, 1) = "0"
Cells(9, 1) = "0"
Cells(10, 1) = "0"
Cells(11, 1) = "1"
Cells(12, 1) = "1"
Cells(13, 1) = "1"
Cells(14, 1) = "1"
Cells(15, 1) = "1"
Cells(16, 1) = "1"
Cells(17, 1) = "1"
Cells(18, 1) = "1"
Cells(19, 1) = "1"
Cells(20, 1) = "1"
Cells(21, 1) = "2"
Cells(22, 1) = "2"
Cells(23, 1) = "2"
Cells(24, 1) = "2"
Cells(25, 1) = "2"
Cells(26, 1) = "2"
Cells(27, 1) = "2"
Cells(28, 1) = "2"
Cells(29, 1) = "2"
Cells(30, 1) = "2"
Cells(31, 1) = "3"
Cells(32, 1) = "3"
Cells(33, 1) = "3"
Cells(34, 1) = "3"
Cells(35, 1) = "3"
Cells(36, 1) = "3"
Cells(37, 1) = "3"
Cells(38, 1) = "3"
Cells(39, 1) = "3"
Cells(40, 1) = "3"
Cells(1, 2) = "1"
Cells(2, 2) = "2"
Cells(3, 2) = "3"
Cells(4, 2) = "4"
Cells(5, 2) = "5"
Cells(6, 2) = "6"
Cells(7, 2) = "7"
Cells(8, 2) = "8"
Cells(9, 2) = "9"
Cells(10, 2) = "10"
Cells(11, 2) = "1"
Cells(12, 2) = "2"
Cells(13, 2) = "3"
Cells(14, 2) = "4"
Cells(15, 2) = "5"
Cells(16, 2) = "6"
Cells(17, 2) = "7"
Cells(18, 2) = "8"
Cells(19, 2) = "9"
Cells(20, 2) = "10"
Cells(21, 2) = "1"
Cells(22, 2) = "2"
Cells(23, 2) = "3"
Cells(24, 2) = "4"
Cells(25, 2) = "5"
Cells(26, 2) = "6"
Cells(27, 2) = "7"
Cells(28, 2) = "8"
Cells(29, 2) = "9"
Cells(30, 2) = "10"
Cells(31, 2) = "1"
Cells(32, 2) = "2"
Cells(33, 2) = "3"
Cells(34, 2) = "4"
Cells(35, 2) = "5"
Cells(36, 2) = "6"
Cells(37, 2) = "7"
Cells(38, 2) = "8"
Cells(39, 2) = "9"
Cells(40, 2) = "10"
nb = 5 ' ====>> pour en oter 5 à chaque extrémité.
If plage Is Nothing Then
Set plage = Range("A1")
Set plage_a_supp = plage
End If
For i = 2 To Rows.Count ' je me moque même de déterminer la dernière ligne remplie
If Range("A" & i).Value = Range("A" & i - 1).Value Then
Set plage = Union(plage, Range("A" & i))
Else
If plage.Rows.Count >= nb Then
For j = 1 To nb
Set plage_a_supp = Union(plage_a_supp, plage(j, 1), plage(plage.Rows.Count + 1 - j, 1))
Next
Set plage = Range("A" & i)
If Range("A" & i).Value = "" Then Exit For
End If
End If
Next
plage_a_supp.EntireRow.Delete
End Sub