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 :

Simplification macro de sélection de courbes


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Inscrit en
    Septembre 2009
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Septembre 2009
    Messages : 2
    Par défaut Simplification macro de sélection de courbes
    Bonjour je débute dans les macro et je souhaiterais comprendre comment faire la chose suivante.
    Dans un graphique lié à un TCD j'ai X courbes je voudrais sélectonner le premier point le chaque courbe. Ma macro est faite mais elle est restrictive à 5 courbes.
    Comment pourrais je la simplifier et ensuite la rendre évolutive selon mon nombre de courbe.
    Je vous envoi si vous avez 5 minutes.
    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    Application.ScreenUpdating = False
        ActiveSheet.PivotTables("Tableau croisé dynamique1").PivotCache.Refresh
        ActiveSheet.ChartObjects("Graphique 2").Activate
        ActiveChart.SeriesCollection(1).Select
        ActiveChart.SeriesCollection(1).Points(1).Select
        ActiveChart.SeriesCollection(1).Points(1).ApplyDataLabels AutoText:=True, _
            LegendKey:=False, ShowSeriesName:=True, ShowCategoryName:=False, _
            ShowValue:=False, ShowPercentage:=False, ShowBubbleSize:=False
        ActiveChart.SeriesCollection(1).DataLabels.Select
        Selection.AutoScaleFont = True
        With Selection.Font
            .Name = "Arial"
            .FontStyle = "Normal"
            .Size = 9
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .Position = xlLabelPositionLeft
            .Orientation = xlHorizontal
        End With
        '2
     
        ActiveChart.SeriesCollection(2).Select
        ActiveChart.SeriesCollection(2).Points(1).Select
        ActiveChart.SeriesCollection(2).Points(1).ApplyDataLabels AutoText:=True, _
            LegendKey:=False, ShowSeriesName:=True, ShowCategoryName:=False, _
            ShowValue:=False, ShowPercentage:=False, ShowBubbleSize:=False
        ActiveChart.SeriesCollection(2).DataLabels.Select
        Selection.AutoScaleFont = True
        With Selection.Font
            .Name = "Arial"
            .FontStyle = "Normal"
            .Size = 9
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .Position = xlLabelPositionLeft
            .Orientation = xlHorizontal
            End With
            '3
     
        ActiveChart.SeriesCollection(3).Select
        ActiveChart.SeriesCollection(3).Points(1).Select
        ActiveChart.SeriesCollection(3).Points(1).ApplyDataLabels AutoText:=True, _
            LegendKey:=False, ShowSeriesName:=True, ShowCategoryName:=False, _
            ShowValue:=False, ShowPercentage:=False, ShowBubbleSize:=False
        ActiveChart.SeriesCollection(3).DataLabels.Select
        Selection.AutoScaleFont = True
        With Selection.Font
            .Name = "Arial"
            .FontStyle = "Normal"
            .Size = 9
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .Position = xlLabelPositionLeft
            .Orientation = xlHorizontal
        End With
    '4
     
        ActiveChart.SeriesCollection(4).Select
        ActiveChart.SeriesCollection(4).Points(1).Select
        ActiveChart.SeriesCollection(4).Points(1).ApplyDataLabels AutoText:=True, _
            LegendKey:=False, ShowSeriesName:=True, ShowCategoryName:=False, _
            ShowValue:=False, ShowPercentage:=False, ShowBubbleSize:=False
        ActiveChart.SeriesCollection(4).DataLabels.Select
        Selection.AutoScaleFont = True
        With Selection.Font
            .Name = "Arial"
            .FontStyle = "Normal"
            .Size = 9
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .Position = xlLabelPositionLeft
            .Orientation = xlHorizontal
        End With
        '5
        ActiveSheet.ChartObjects("Graphique 2").Activate
        ActiveChart.SeriesCollection(5).Select
        ActiveChart.SeriesCollection(5).Points(1).Select
        ActiveChart.SeriesCollection(5).Points(1).ApplyDataLabels AutoText:=True, _
            LegendKey:=False, ShowSeriesName:=True, ShowCategoryName:=False, _
            ShowValue:=False, ShowPercentage:=False, ShowBubbleSize:=False
        ActiveChart.SeriesCollection(5).DataLabels.Select
        Selection.AutoScaleFont = True
        With Selection.Font
            .Name = "Arial"
            .FontStyle = "Normal"
            .Size = 9
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .Background = xlAutomatic
        End With
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .Position = xlLabelPositionLeft
            .Orientation = xlHorizontal
            End With
            Application.ScreenUpdating = True
    End Sub
    Merci d'avance

  2. #2
    Membre Expert
    Inscrit en
    Août 2006
    Messages
    1 588
    Détails du profil
    Informations forums :
    Inscription : Août 2006
    Messages : 1 588
    Par défaut
    Créer une procédure FormatageGraphe par exemple
    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
    Sub FormatageGraphe(graphe as string, ligne as long)
     ActiveSheet.ChartObjects(graphe).Activate
     ActiveChart.SeriesCollection(ligne).Select
     ActiveChart.SeriesCollection(ligne).Points(1).Select
     ActiveChart.SeriesCollection(ligne).Points(1).ApplyDataLabels AutoText:=True, _
     LegendKey:=False, ShowSeriesName:=True, ShowCategoryName:=False, _
     ShowValue:=False, ShowPercentage:=False, ShowBubbleSize:=False
     ActiveChart.SeriesCollection(ligne).DataLabels.Select
     Selection.AutoScaleFont = True 
     With Selection.Font
      .Name = "Arial"
      .FontStyle = "Normal"
      .Size = 9
      .Strikethrough = False
      .Superscript = False
      .Subscript = False
      .OutlineFont = False
      .Shadow = False
      .Underline = xlUnderlineStyleNone
      .ColorIndex = xlAutomatic
      .Background = xlAutomatic
     End With
     With Selection
     .HorizontalAlignment = xlCenter
     .VerticalAlignment = xlCenter
     .Position = xlLabelPositionLeft
     .Orientation = xlHorizontal
     End With
    End Sub
    qui sera utiliser de cette façon
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
     For i = 1 To 5
      Call FormatageGraphe("Graphique 2", i )
     Next i
    Ca parait même plus clair et surtout moins long

  3. #3
    Nouveau candidat au Club
    Inscrit en
    Septembre 2009
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Septembre 2009
    Messages : 2
    Par défaut
    Je suis désolé je nage avec cette solution, je ne sais pas trop comment l'installer.

Discussions similaires

  1. macro et sélection d'obervations
    Par yemal dans le forum Macro
    Réponses: 3
    Dernier message: 19/08/2011, 10h01
  2. [XL-2003] lancer des macros à la sélection de feuilles
    Par AstridT dans le forum Macros et VBA Excel
    Réponses: 14
    Dernier message: 24/05/2011, 18h29
  3. Simplification macro répétitive
    Par teddy72000 dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 15/03/2011, 16h26
  4. Simplification macro de sauvegarde
    Par NEC14 dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 30/07/2010, 11h25

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