Bonjour,
je reviens vers vous pour une question d'organisation de ce tableau,
j'aimerais que visuellement cela ressemble à une cascade comme l'image en PJ:
pouvez-vous m'aider à réctifier le code de ma macro?
Sub insererLignes()
Dim derLig As Long, nbLig As Long, i As Long, j As Long, derCol As Long, car As Integer
derLig = Range("A" & Rows.Count).End(xlUp).Row
For i = derLig To 2 Step -1
derCol = Cells(1, Cells.Columns.Count).End(xlToLeft).Column
nbLig = WorksheetFunction.Max(Range(Cells(i, 2), Cells(i, derCol)))
If nbLig = 0 Then nbLig = 1 ' ICI JE METS 1 SI C'EST ZERO
Rows(i + 1).Resize(nbLig).Insert shift:=xlDown
Cells(i, 1).Copy Destination:=Range(Cells(i + 1, 1), Cells(i + nbLig, 1))
For j = 2 To derCol
car = Cells(i, j)
If car <> 0 Then
If j = 3 Then
Range(Cells(i + 1, j), Cells(i + car, j)) = UCase(Left(Cells(1, j), 2))
Else
Range(Cells(i + 1, j), Cells(i + car, j)) = UCase(Left(Cells(1, j), 1))
End If
End If
Next j
derLig = Range("A" & Rows.Count).End(xlUp).Row
Next i
End Sub
Merci d'avence.
Cordialement.
Voilà le fichier: