bonsoir, monsieur l'impatient énervé que je n'ai pas vraiment envie d'aider ! Qui a l'air d'oublier que les gens qui aident sont bénévoles.
mais comme j'avais travaillé sur un code, je le mets quand même à disposition en toute magnanimité
bonne chance !
Sub gentables()
Dim ws As Worksheet
Dim ws1 As Worksheet
Set ws = Worksheets("BDD")
Set ws1 = Worksheets("Feuil3"): 'résultat dans Feuil3
derlig = ws.Range("a:a").End(xlDown).Row
ws1.Cells.Clear
ws1.Range("A1") = "TITRE"
ws1.Range("A1:E1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
ws.Range("a1:E" & derlig).Copy
ws1.Range("a2").Select
ActiveSheet.Paste
Columns("A:E").Select
Application.CutCopyMode = False
ws1.Sort.SortFields.Clear
ws1.Sort.SortFields.Add Key:=Range("A1:A" & derlig) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ws1.Sort
.SetRange Range("A2:E" & derlig)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
rup = ws1.Cells(derlig, 1)
For i = derlig - 1 To 3 Step -1
If ws1.Cells(i, 1) <> rup Then
ws1.Rows("1:2").Select
Selection.Copy
ws1.Rows(i + 1 & ":" & i + 1).Insert Shift:=xlDown
Application.CutCopyMode = False
ws1.Rows(i + 1 & ":" & i + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
rup = ws1.Cells(i, 1)
End If
Next i
Set ws = Nothing
Set ws1 = Nothing
End Sub