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 :

Nommer un graphique au moment de l'ajout [XL-2003]


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2009
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2
    Par défaut Nommer un graphique au moment de l'ajout
    Bonjour à tous,

    puisque c'est mon premier post ici je précise que je ne suis pas un pro de l'informatique mais plutôt un autodidacte, merci de votre indulgence si je pose des questions idiotes !

    Voici mon problème :

    Je lance plusieurs macros sur une feuille et chaque macro me crée un graph. Chaque graph est automatiquement nommé "Graphique 1", "Graphique 2", etc, puis je réutilise ce nom pour renommer et placer mon graph dans la page.

    Du coup, si je n'exécute pas les macros dans l'ordre, ça ne marche pas.
    Ma question c'est : est-il possible de définir ce nom en amont au moment de l'ajout dans la page afin que le nom de base soit toujours le même ? (j'ai fait une chose comme ça pour ajouter des nouvelles feuilles dans mon classeur avec toujours le même nom mais je n'ai pas réussi à le reproduire pour les graphs...)
    Ou bien de désactiver l'incrémentation ???

    pour info, voici le code complet de ma macro :
    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
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    Dim feuille As Worksheet
    Dim plage As Range
    ' DECLARATION tableau avec tous les noms des feuilles
    Set feuilles = Sheets(Array("AIGUEPERSE", "ALBIGNY-SUR-SAONE", "ALIX", "AMPLEPUIS", "AMPUIS", "ANSE", "ARNAS", "AVEIZE", "AVENAS", "BAGNOLS", "BEAUJEU", "BELLEVILLE", "BESSENAY", "BLACÉ", "BOURG DE THIZY", "BRIGNAIS", "BRINDAS", "BRULLIOLES", "BRUSSIEU", "BULLY", "CAILLOUX-SUR-FONTAINES", "CHAMBOST-LONGESSAIGNE", "CHAMELET", "CHAMPAGNE-AU-MONT-D'OR", "CHAPONNAY", "CHAPONOST", "CHARBONNIERES-LES-BAINS", "CHARENTAY", "CHARLY", "CHARNAY", "CHASSAGNY", "CHASSELAY", "CHASSIEU", "CHATILLON D'AZERGUES - CHESSY", "CHAUSSAN", "CHAZAY D'AZERGUES", "CHEVINAY", "CHIROUBLES", "CLAVEISOLLES", "COGNY", "COISE", "COLLONGES-AU-MONT-D'OR", "COLOMBIER-SAUGNIEU", "COMMUNAY", "CONDRIEU", "CORBAS", "CORCELLES-EN-BEAUJOLAIS", "COURS-LA-VILLE", "COURZIEU", "COUZON-AU-MONT-D'OR", "CRAPONNE", "CUBLIZE", "CURIS-AU-MONT-D'OR", "DARDILLY", "DENICÉ", "DOMMARTIN", "DUERNE", "ECHALAS", "EVEUX", "FEYZIN", "FLEURIE", "FLEURIEU-SUR-SAONE", "FLEURIEUX-SUR-L'ARBRESLE", "FONTAINES-SUR-SAONE", "FRANCHEVILLE"))
     
    For Each feuille In feuilles
    ' DECLARATION plage des données source
    Set plage = feuille.Range("AO1:AO8")
    Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SetSourceData Source:=plage, PlotBy _
    :=xlColumns
    ActiveChart.SeriesCollection(1).XValues = feuille.Range("A2:A8")
    ActiveChart.SeriesCollection(1).Name = feuille.Range("AO1")
    ' MISE EN FORME localisation du graphique dans la feuille
    ActiveChart.Location Where:=xlLocationAsObject, Name:=feuille.Name
    ' MISE EN FORME titre légende
    With ActiveChart
    .HasTitle = True
    .ChartTitle.Characters.Text = "Evolution des prêts MD Vidéo"
    .Axes(xlCategory, xlPrimary).HasTitle = False
    .Axes(xlValue, xlPrimary).HasTitle = False
    .HasLegend = False
    End With
    ActiveChart.HasLegend = False
    ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowValue, LegendKey:=False
    ' MISE EN FORME changement de couleur
    ActiveChart.SeriesCollection(1).Points(1).Select
    With Selection.Border
    .Weight = xlThin
    .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
    ' vert relais
    .ColorIndex = 43
    .Pattern = xlSolid
    End With
    ActiveChart.SeriesCollection(1).Points(2).Select
    With Selection.Border
    .Weight = xlThin
    .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
    ' vert relais
    .ColorIndex = 43
    .Pattern = xlSolid
    End With
    ActiveChart.SeriesCollection(1).Points(3).Select
    With Selection.Border
    .Weight = xlThin
    .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
    ' vert relais
    .ColorIndex = 43
    .Pattern = xlSolid
    End With
    ActiveChart.SeriesCollection(1).Points(4).Select
    With Selection.Border
    .Weight = xlThin
    .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
    ' vert relais
    .ColorIndex = 43
    .Pattern = xlSolid
    End With
    ActiveChart.SeriesCollection(1).Points(5).Select
    With Selection.Border
    .Weight = xlThin
    .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
    ' vert relais
    .ColorIndex = 43
    .Pattern = xlSolid
    End With
    ActiveChart.SeriesCollection(1).Points(6).Select
    With Selection.Border
    .Weight = xlThin
    .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
    ' bleu réseau
    .ColorIndex = 41
    .Pattern = xlSolid
    End With
    ActiveChart.SeriesCollection(1).Points(7).Select
    With Selection.Border
    .Weight = xlThin
    .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
    ' jaune md
    .ColorIndex = 44
    .Pattern = xlSolid
    End With
    ' MISE EN FORME renommer le graphique pour pouvoir le placer
    ActiveSheet.Shapes("Graphique 19").Name = "PMDVID"
    With ActiveSheet.Shapes("PMDVID")
    .Left = Range("B370").Left
    .Top = Range("B370").Top
    End With
    ' FORMATAGE ne pas déplacer et dimensionner avec les cellules
    With ActiveSheet.DrawingObjects("PMDVID")
    .Placement = xlFreeFloating
    .PrintObject = True
    End With
    ActiveSheet.DrawingObjects("PMDVID").Locked = True
     
    Next
     
    End Sub
    Merci de votre aide

    Ludoxa

  2. #2
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2009
    Messages
    48
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 48
    Par défaut
    Bonjour,
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    'ActiveSheet.ChartObjects(1).Name = 'Le nom du Graphique'  CHANGER LE NOM
    'ActiveSheet.ChartObjects.Add(POSGAUCHE,POSSOMMET,LARGEUR, HAUTEUR).Name = ("Graphique 1")
    'creation d'un graphique
    ActiveSheet.ChartObjects.Add(0, 0, 720, 450).Name = ("Graphique 1")
        ActiveSheet.ChartObjects("Graphique 1").Activate
        ActiveChart.ChartType = xlLine
        ActiveChart.SetSourceData Source:=Sheets("ATELIER").Range(Cells(1, 5), Cells(100, 5))
     'ajouter une tendance   
            ActiveSheet.ChartObjects("Graphique 1").Activate
            ActiveChart.SeriesCollection.NewSeries
            ActiveChart.SeriesCollection(2).Values = Sheets("ATELIER").Range(Cells(1, 8), Cells(100, 8))
    Par contre si tu mets toujours le meme nom, je crains un confflit

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

Discussions similaires

  1. Nommer un graphique a partir d'une cellule
    Par Potzo dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 02/07/2010, 10h06
  2. [PR-2007] Erreur au moment de l'ajout d'un livrable au projet
    Par Jean-Claude Dusse dans le forum Project
    Réponses: 2
    Dernier message: 26/07/2009, 17h48
  3. Nommer des graphiques
    Par babybell dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 02/03/2009, 10h42
  4. Nommer des graphiques
    Par nono le golfeur dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 02/07/2007, 18h31
  5. A quel moment docmd.runsql ajoute-t-il les donnés ?
    Par pascalouh dans le forum VBA Access
    Réponses: 5
    Dernier message: 16/06/2007, 20h31

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