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 :

[XL-Graph]: mise à jour / double click


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    128
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations forums :
    Inscription : Septembre 2006
    Messages : 128
    Par défaut [XL-Graph]: mise à jour / double click
    Bonjour,

    Me revoila avec mes questions fouareuses ...

    Mes macros me créés pleins de tableaux, et créés aussi 2 graphs associés.
    J'ai créé une coloration conditionnelle des séries selon mes valeurs.
    Mais certaines données sont manquantes et devront etre rajoutées à la main.
    Je voudrais donc que cette coloration conditionnelle puisse etre relancée par un double click sur le graph.

    Ne tapez pas, j'ai cherché avant de vous poser la question, mais rien ne marche

    Est ce que qq peut m'aider ????
    Merci bp, je commence à craquer !

    Pour info, voici le code des graphs (coloration cond. à la fin....)
    Et n'hésitez pas à me faire des remarques si ma macro vous parait mal codée, ca me fera progresser
    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
     
    Sub MinigraphD(pl)
    Dim LinMiniTab As Double
    Dim TpsPrev As Double
    Dim TpsReel As Double
    LinMiniTab = 12 * pl + 4
     
    'Création du minigraph
    Charts.Add
    ActiveChart.Location _
        Where:=xlLocationAsObject, Name:="Bilan"
        ActiveChart.ChartType = xlColumnClustered
        ActiveChart.SetSourceData Source:=Sheets("Bilan").Range("B18:B19"), PlotBy _
            :=xlRows
        ActiveChart.SeriesCollection(1).Delete
        ActiveChart.SeriesCollection.NewSeries
        ActiveChart.SeriesCollection.NewSeries
        ActiveChart.SeriesCollection(1).XValues = "=Bilan!R18C3:R18C4"
        ActiveChart.SeriesCollection(1).Values = "=Bilan!R19C3:R19C4"
        ActiveChart.SeriesCollection(1).Name = "=Bilan!R19C2"
        ActiveChart.Location Where:=xlLocationAsObject, Name:="Bilan"
     
    With ActiveChart
        .SetSourceData Range("B" & pl * 12 + 6 & ":D" & pl * 12 + 6 & ",B" & pl * 12 + 8 & ":D" & pl * 12 + 8)
        .HasTitle = False
        .ChartType = xlColumnClustered
        .HasLegend = True
        .Axes(xlCategory).TickLabels.Orientation = xlHorizontal
        .PlotArea.Top = 0
        .PlotArea.Top = 100
        .PlotArea.Height = 300
        .Axes(xlValue).MaximumScaleIsAuto = True
        .HasDataTable = Worksheets("Bilan").TableBox.Value
    End With
     
     
    'Placement/Dimensionnement du minigraph
    ActiveSheet.ChartObjects(ActiveChart.Parent.Name).Name = "GraphD" & pl
     
    With ActiveSheet.ChartObjects("GraphD" & pl)
    .Left = Range("G" & pl).Left
    .Top = Range("B" & (12 * pl + 4)).Top
    .Width = Range("G" & (12 * pl + 4) & ":I" & (12 * pl + 13)).Width
    .Height = Range("B" & (12 * pl + 4) & ":D" & (12 * pl + 13)).Height
    End With
     
    'Formatage du minigraph
    ActiveChart.PlotArea.Select
        Selection.Top = 1
        Selection.Left = 1
        Selection.Height = 194
        Selection.Width = 350
     
    With ActiveChart
        .Axes(xlValue).Select
        .Axes(xlValue).TickLabels.AutoScaleFont = True
        .Axes(xlValue).MinimumScale = 0
        .Legend.Select
    End With
     
    ActiveChart.Axes(xlValue).TickLabels.AutoScaleFont = True
     
    With ActiveChart.Axes(xlValue).TickLabels.Font
        .Name = "Arial"
        .FontStyle = "Normal"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .Background = xlAutomatic
    End With
     
     
    Selection.Left = 140
    Selection.Top = 1
     
    'Coloration conditionnelle
    If Worksheets("Bilan").Colorbox.Value = True Then
     
        TpsPrev = IIf(IsError(ThisWorkbook.Worksheets("Bilan").Cells(pl * 12 + 8, 3).Value), 0, ThisWorkbook.Worksheets("Bilan").Cells(pl * 12 + 8, 3).Value)
        TpsReel = IIf(IsError(ThisWorkbook.Worksheets("Bilan").Cells(pl * 12 + 8, 4).Value), 0, ThisWorkbook.Worksheets("Bilan").Cells(pl * 12 + 8, 4).Value)
        ActiveChart.SeriesCollection(1).Select
     
        'Calcul pour colaration
        Select Case TpsReel
                Case Is > TpsPrev
                ActiveChart.SeriesCollection(1).Select
                With Selection.Interior
                .ColorIndex = 3
                .Pattern = xlSolid
                End With
     
                Case Is > TpsPrev - TpsPrev * 20 / 100
                ActiveChart.SeriesCollection(1).Select
                With Selection.Interior
                .ColorIndex = 46
                .Pattern = xlSolid
                End With
     
                Case Is < TpsPrev
                ActiveChart.SeriesCollection(1).Select
                With Selection.Interior
                .ColorIndex = 50
                .Pattern = xlSolid
                End With
        End Select
     
    Else
     
     
    ActiveChart.SeriesCollection(1).Select
    With Selection.Interior
    .ColorIndex = 44
    .Pattern = xlSolid
    End With
    End If
     
     
    Range("K10").Select
     
    End Sub

  2. #2
    Inactif  
    Avatar de ouskel'n'or
    Profil pro
    Inscrit en
    Février 2005
    Messages
    12 464
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 12 464
    Par défaut
    Un simple clic, ça t'irait ?
    Tu écrits ta macro de formatage conditionnel puis tu fais un clic droit sur ton graph. Tu as une fenêtre qui s'ouvre avec, tout en bas "Affecter une macro". Là, tu mets le nom de ta macro

  3. #3
    Expert confirmé

    Homme Profil pro
    Inscrit en
    Août 2005
    Messages
    3 317
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2005
    Messages : 3 317
    Par défaut
    bonjour

    j'espère que ce lien pourra t'aider


    http://silkyroad.developpez.com/VBA/...ntsGraphiques/


    michel

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    128
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations forums :
    Inscription : Septembre 2006
    Messages : 128
    Par défaut
    Merci pour vos réponses, ca fait du bien d'avoir de l'aide

    J'avais déjà vu le lien mais je n'ai pas le niveau pour faire qq chose avec tout ca ! Mais il faudrait que je m'y replonge !

    Sinon pour le coup d'affecter une macro à un grapg, je n'avais jamais fait attention à cette possibilité !
    Et avant de maitriser les Byval et Byref et tous ces trucs qui me font peu, je vais utiliser cette option.

    Encore merci pour votre aide !!

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

Discussions similaires

  1. [XL-2007] génerer des points et mise à jour des couleurs sur un graphe radar
    Par hobine dans le forum Macros et VBA Excel
    Réponses: 0
    Dernier message: 14/05/2013, 08h57
  2. [PPT-2010] double mise à jour powerpoint excel csv
    Par christype0 dans le forum Powerpoint
    Réponses: 0
    Dernier message: 24/01/2013, 13h29
  3. [AC-2007] Mise à jour KB979440 - Graphique (graphs) défectueux
    Par Observateur dans le forum IHM
    Réponses: 6
    Dernier message: 14/08/2010, 11h04
  4. [Débutant] mise à jour d'un graphe entre 2 fonctions
    Par Luis Vieira da Silva dans le forum Interfaces Graphiques
    Réponses: 3
    Dernier message: 06/07/2009, 13h20
  5. Problème click Once et mises à jour
    Par Shypster dans le forum C#
    Réponses: 4
    Dernier message: 20/05/2008, 10h18

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