Bonjour à tous,
Voilà quelques heures que j'essaye de comprendre d'où vient l'erreur...
Je ne peux vous faire parvenir le fichier cependant je vous joins une capture d'écran pour que vous puissiez illustrer le code (notamment l'aspect colonnes & lignes concernées).
Mon code ci-dessous sert à changer la maille horaire du Gantt automatisé et donc redessiner en fonction les tâches et les connecteurs. Ça marche pour les tâches mais ça déconne sur les connecteurs à la ligne du code :
Loop Until (.Cells(ligne + 1, i).Value = 1 Or i > der_col)
Ci-dessous le code complet et en PJ les captures :
Sub DessinConnecteur(ligne As Long)
Dim prem_col As Long, der_col As Long
Dim coldebut As Long, coldebut2 As Long, colfin As Long, i As Long
Dim PointHlosange As Single, PointHlosangefin As Single, PointVlosange As Single
Dim PointH As Single, PointHzero As Single, PointVzero As Single, PointHFin As Single, PointHA As Single
Dim Sh As Shape, Shlosange As Shape
Sheets("RoadCard").Unprotect "maelle33"
prem_col = 11
der_col = 159
With ActiveSheet
i = prem_col - 1
Do: i = i + 1
Loop Until (.Cells(ligne, i).Value = 1 Or i > der_col)
coldebut = i
Do: i = i + 1
Loop Until (.Cells(ligne, i).Value = "" Or i > der_col)
colfin = i - 1
PointHA = 0
For i = 1 To colfin
PointHA = PointHA + .Columns(i).Width
Next i
PointH = 0
For i = 1 To coldebut - 1
PointH = PointH + .Columns(i).Width
Next i
PointHlosange = PointH - (.Columns(prem_col).Width / 4)
PointHzero = 0
For i = 1 To colfin
PointHzero = PointHzero + .Columns(i).Width
Next i
PointHlosangefin = PointHzero - (.Columns(prem_col).Width / 4)
PointVzero = 0
For i = 1 To ligne - 1
PointVzero = PointVzero + .Rows(i).Height
Next i
PointVlosange = PointVzero + (.Rows(ligne).Height) / 5
PointVzero = PointVzero + (.Rows(ligne).Height) / 2
i = prem_col - 1
Do: i = i + 1
Loop Until (.Cells(ligne + 1, i).Value = 1 Or i > der_col)
coldebut2 = i
PointHFin = 0
For i = 1 To coldebut2 - 1
PointHFin = PointHFin + .Columns(i).Width
Next i
If (coldebut2 > der_col Or PointHFin < PointHzero) Then PointHFin = PointHzero + 20
If (coldebut < der_col) Then
Set Shlosange = .Shapes.AddShape(msoShapeDiamond, PointHlosange, PointVlosange, 6, 10)
With Shlosange
.Fill.ForeColor.RGB = RGB(192, 0, 0)
.Line.ForeColor.RGB = RGB(192, 0, 0)
End With
Set Shlosange = .Shapes.AddShape(msoShapeDiamond, PointHlosangefin, PointVlosange, 6, 10)
With Shlosange
.Fill.ForeColor.RGB = RGB(192, 0, 0)
.Line.ForeColor.RGB = RGB(192, 0, 0)
End With
If coldebut2 < der_col Then
Set Sh = .Shapes.AddConnector(msoConnectorElbow, PointHzero, PointVzero, PointHFin, PointVzero + (.Rows(ligne).Height))
With Sh.Line
.EndArrowheadStyle = msoArrowheadTriangle
.ForeColor.ObjectThemeColor = 13
End With
End If
End If
' If .Cells(ligne, 9).Value > 0 Then Call Avancement(ligne, PointVzero, PointH, PointHA)
End With
Sheets("RoadCard").Protect "maelle33"
End Sub
Merci de votre aide