Bonjour a tous,

Contexte:
J'essaie de recréer un Gantt entre 1 et 5 lignes dans Excel.
Normalement j'ai 2 dates (début - fin) mais dans le cas de milestones je n'en ai plus qu'une, c est pourquoi j'ai crée un bout de code sur la gestion d'erreurs.

Problème:
La variable "lengant" définit le nombre de ligne a boucler (entre 1 et 5).
La boucle For est censé restreindre la boucle a son max : 5.
Le problème est que la boucle continue a tourner a l'infini. Je n'arrive pas a la terminer a "lengant". Pourquoi ?

Merci de m'aider

Code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
On Error GoTo except:
 
For idxline = 1 To 5
 
If idxline = lengant + 1 Then GoTo suite:
 
    strLabel = "Finish" & idxline
    Application.Goto Reference:=strLabel
    firstCellRow = ActiveCell.Row
    firstCellCol = ActiveCell.Column
    strLabel = "Start" & idxline
    Application.Goto Reference:=strLabel
    lastCellRow = ActiveCell.Row
    lastCellCol = ActiveCell.Column
 
X:
    Range(Cells(firstCellRow, firstCellCol), Cells(lastCellRow, lastCellCol)).Select
    With Selection.Interior
            .ColorIndex = 37
            .Pattern = xlSolid
    End With
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
 
 Next idxline
 
except:
    codestrLabel = Left(strLabel, 4)
    idxstrLabel = Right(strLabel, 1)
 
    If codestrLabel = "Fini" Then
        Application.Goto Reference:="Start" & idxstrLabel
    ElseIf codestrLabel = "Star" Then
        Application.Goto Reference:="Finish" & idxstrLabel
    End If
 
    lastCellRow = ActiveCell.Row
    lastCellCol = ActiveCell.Column
    firstCellRow = lastCellRow
    firstCellCol = lastCellCol
    Err.Clear
    Resume X: