IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

[E-03] Création de graph dans une boucle


Sujet :

Macros et VBA Excel

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 2
    Points : 2
    Points
    2
    Par défaut [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 : 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
     
     
    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 : 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
    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

  2. #2
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 2
    Points : 2
    Points
    2
    Par défaut
    Bonjour à tous et bonne année,

    Je me suis pris autrement pour plus d'infos je me suis inspiré du site suivant:

    http://www.cathyastuce.com/vba/obj_xl_graph_series.php

    Super site!!!

    Salut

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Création de contrôles dans une boucle
    Par koktel_dfr dans le forum Windows Forms
    Réponses: 3
    Dernier message: 22/01/2010, 14h36
  2. [MySQL] Création de variables dans une boucle et récupération de données avec une requête
    Par lavande4 dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 15/09/2008, 11h10
  3. Création d'objets dans une boucle for
    Par urban_p dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 02/06/2008, 10h34
  4. Création d'instance dans une boucle ?
    Par stabe dans le forum C#
    Réponses: 15
    Dernier message: 03/01/2008, 16h48
  5. probleme de création de variable dans une boucle
    Par misterweb dans le forum Langage
    Réponses: 2
    Dernier message: 16/01/2007, 19h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo