[E-03] Création de graph dans une boucle
	
	
		Bonjour,
J'ai un petit souci voilà j'ai fais un dev pour créer une série de graph en fonction des valeurs saisies dans des cellules de ma feuille excel.
Voici le code :
	Code:
	
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
   |  
 
Sub Macro()
 
    r = Cells(10, 2)
    U = Cells(12, 2)
    Z = U + Cells(9, 2)
    i = Cells(11, 2)
    pt = Cells(19, 2)
    pas = Cells(20, 2)
 
 
    extrememini = Cells(12, 2) + Cells(9, 2) - Cells(15, 2)
    extrememaxi = Cells(12, 2) + Cells(9, 2) + Cells(15, 2)
 
    Charts.Add
    ActiveChart.ChartType = xlXYScatter
    ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("F11")
 
 
    For N = 0 To i - 1
    i = Z + N * r
    tmini = extrememini + N * r
    tmaxi = extrememaxi + N * r
    tete = pt + N * pas | 
      ' c'est la partie qui suit qui ne va pas , j'ai vérifié pas à pas...dans ma prémier boucle j'ai bien mes 4 droites. Le problème vient dans les boucles suivantes, je ne garde pas les droites( il y a un écrasement des droite créee à la prémier boucle, après réflexion la valeur entre parenthéze (N+1) "ActiveChart.SeriesCollection(N + 1)". doit être unique pour chaque droite jusqu'a la fin de la boucle, je n'ai pas trouvé la solution pour donner une identité unique à mes droites jusqu'a la fin de ma boucle for
  
Merci de votre aide!    
	Code:
	
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
   |  
ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(N + 1).XValues = Array(i, i)
    ActiveChart.SeriesCollection(N + 1).Values = Array(0, 2)
    ActiveChart.SeriesCollection(N + 1).Name = "=""panne" + CStr(N + 1) + """"
 
 
    ActiveChart.SeriesCollection(N + 2).XValues = Array(tmini, tmini)
    ActiveChart.SeriesCollection(N + 2).Values = Array(0, 2)
    ActiveChart.SeriesCollection(N + 2).Name = "=""Mini" + CStr(N + 1) + """"
 
 
    ActiveChart.SeriesCollection(N + 3).XValues = Array(tmaxi, tmaxi)
    ActiveChart.SeriesCollection(N + 3).Values = Array(0, 2)
    ActiveChart.SeriesCollection(N + 3).Name = "=""Maxi" + CStr(N + 1) + """"
 
 
    ActiveChart.SeriesCollection(N + 4).XValues = Array(tete, tete)
    ActiveChart.SeriesCollection(N + 4).Values = Array(0, 2)
    ActiveChart.SeriesCollection(N + 4).Name = "=""Tête" + CStr(N + 1) + """"
 
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
    ActiveChart.HasLegend = True
    ActiveChart.Legend.Select
    Selection.Position = xlRight
 
 
 
    ActiveChart.SeriesCollection(N + 1).Select
    With Selection.Border
        .ColorIndex = 1
        .Weight = xlHairline
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = xlAutomatic
        .MarkerForegroundColorIndex = xlAutomatic
        .MarkerStyle = xlAutomatic
        .Smooth = True
        .MarkerSize = 3
        .Shadow = False
    End With
 
    ActiveChart.SeriesCollection(N + 2).Select
    With Selection.Border
        .ColorIndex = 8
        .Weight = xlHairline
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = xlAutomatic
        .MarkerForegroundColorIndex = xlAutomatic
        .MarkerStyle = xlAutomatic
        .Smooth = True
        .MarkerSize = 3
        .Shadow = False
    End With
 
    ActiveChart.SeriesCollection(N + 3).Select
    With Selection.Border
        .ColorIndex = 8
        .Weight = xlHairline
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = xlAutomatic
        .MarkerForegroundColorIndex = xlAutomatic
        .MarkerStyle = xlAutomatic
        .Smooth = True
        .MarkerSize = 3
        .Shadow = False
    End With
 
    ActiveChart.SeriesCollection(N + 4).Select
    With Selection.Border
        .ColorIndex = 6
        .Weight = xlHairline
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = xlAutomatic
        .MarkerForegroundColorIndex = xlAutomatic
        .MarkerStyle = xlAutomatic
        .Smooth = True
        .MarkerSize = 3
        .Shadow = False
    End With    
 
    Next N
 
 
 
End Sub |