Sub MiseEnformerack_Plan_G_B()
'variable
Dim sh As Shape, r, NbRangee&, nbtravee&, Coorx&, Coory&, n&, ligne&, arrSh()
Dim tab_SHP() As Variant, v&, shp As Shape
n = 0
NbRangee = Feuil6.Range("C2").Value 'nb derangée
' On vide l'existant
For i = ActiveSheet.Shapes().Count To 1 Step -1
ActiveSheet.Shapes(i).Delete
Next i
' Valeurs de départ
Coorx = 300: Coory = 20
'Boucle des rangées
For nbligne = 1 To NbRangee
ligne = nbligne + 1
nbtravee = Cells(ligne, 2).Value
n = n + 1
'Boucle des travées
ReDim arrSh(nbtravee)
For t = 1 To nbtravee
With ActiveSheet.Shapes().AddShape(msoShapeRectangle, Coorx, Coory, 32, 10)
nom = Cells(ligne, 1) & t
.Line.Weight = 1.5
.Line.ForeColor.RGB = RGB(30, 144, 255)
.Fill.ForeColor.RGB = RGB(255, 255, 255)
.Name = nom
With .TextFrame.Characters
.Font.Size = 7: .Font.Color = vbBlack: .Text = nom
End With
.TextFrame2.VerticalAnchor = msoAnchorMiddle
.TextFrame2.TextRange.ParagraphFormat.Alignment = msoAlignCenter
arrSh(t) = .Name
End With
' Position suivante
Coorx = Coorx + 32
If t = nbtravee Then
ActiveSheet.Shapes.Range(arrSh).Group.Name = "Rangée_" & Cells(ligne, 1).Value
Erase arrSh
Coorx = 300
Coory = Coory + 15
End If
Next t
Next nbligne
MsgBox "Le plan général a été crée !"
End Sub