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 :

Graphique sur choix de zone


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
    Profil pro
    Inscrit en
    Janvier 2010
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Janvier 2010
    Messages : 1
    Par défaut Graphique sur choix de zone
    Bonjour,

    je ne connais rien en vba, mais pour mon travail dans le réseau de la santé, je dois élaborer un programme, dans le cadre d'une démarche d'agrément des hôpitaux.

    Voici ce dont j'ai besoin :
    dans une feuille de calcul, j'ai 13 colonnes période 1..période13
    chaque période contient 10 lignes avec des nombres
    je voudrais que quand j'identifie la période un graphique apparaisse

    Pourriez-vous s'il vous plaît m'expliquer ce que je dois faire ?
    Merci

  2. #2
    Membre averti
    Homme Profil pro
    Technicien Qualité Logiciel
    Inscrit en
    Janvier 2010
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien Qualité Logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2010
    Messages : 44
    Par défaut
    Bonjour!

    Voilà je t'ai fait une petite macro et je vais t'expliquer comment l'adapter ou la modifier ^^

    Le but de cette macro :
    - Pose une question pour récupérer la période
    - Création du graphique en prenant la plage de donnée suivant la période

    Tu peux changer la question au niveau de : Saisir une période de 1 à 13
    Tu n'as surement pas les même plage de donnée que moi, donc tu peux les modifier au niveau de Range("B2:B11")

    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
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    Sub Macro1()
     
        'Déclaration des variables
        Dim sResultatInputBox As String 'Récupére la réponse de l'inputbox
     
        'Ouverture de la imputbox pour récupérer la période
        sResultatInputBox = InputBox("Saisir une période de 1 à 13")
     
        'Création du graphique suivant la réponse
        If sResultatInputBox = 1 Then
            'Ajout d'un nouveau graphique
            Charts.Add
            'Récupération de la plage de données
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("B2:B11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 2 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("C2:C11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 3 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("D2:D11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 4 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("E2:E11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 5 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("F2:F11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 6 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("G2:G11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 7 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("H2:H11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 8 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("I2:I11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 9 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("J2:J11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 10 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("K2:K11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 11 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("L2:L11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 12 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("M2:M11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        ElseIf sResultatInputBox = 13 Then
            Charts.Add
            ActiveChart.SetSourceData Source:=Sheets("Feuil1").Range("N2:N11"), PlotBy _
            :=xlColumns
            ActiveChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
            With ActiveChart
                .HasTitle = False
                .Axes(xlCategory, xlPrimary).HasTitle = False
                .Axes(xlValue, xlPrimary).HasTitle = False
            End With
     
        End If
     
    End Sub
    Voilà j'espère que ça pourrait t'aider, si tu n'arrives pas à inscrire la plage de donnée, ou d'exécuter la macro n'hésite pas.

    Bonne journée!

Discussions similaires

  1. SSH invoquer application graphique sur serveur distant
    Par knecmotet dans le forum Réseau
    Réponses: 7
    Dernier message: 07/09/2008, 19h33
  2. Choix de carte graphique sur ancien matériel
    Par ludo.guy dans le forum Composants
    Réponses: 4
    Dernier message: 23/05/2006, 11h05
  3. Conseil sur choix base de donnée "individuelle"
    Par Rica dans le forum Décisions SGBD
    Réponses: 5
    Dernier message: 12/05/2005, 13h16
  4. Modélisation graphique - Quel choix ?
    Par netah25 dans le forum C++Builder
    Réponses: 2
    Dernier message: 03/03/2005, 17h17
  5. Réponses: 7
    Dernier message: 28/04/2004, 16h51

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