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 :

Génération de graphique sur la même feuille que les données [XL-2007]


Sujet :

Macros et VBA Excel

  1. #1
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut Génération de graphique sur la même feuille que les données
    Bonsoir à tous,

    J'ai deux champs (Dates et Nbre), sur une feuille Excel, je voudrai récupéré les données de ces champs et en faire un graphe, mais le graphe doit se trouver sur la même feuille que les données. Voici un petit bout de code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Sub AutoGraph()
     
     
     
    Dim objChart As Chart, objRange As Range
     
        Set objRange = Worksheets("Feuil1").Range(Worksheets("Feuil1").Cells(1, 1), Worksheets("Feuil1").Cells(21, 3))
        Set objChart = ThisWorkbook.Charts.Add
        objChart.ChartType = xlXYScatter
        objChart.SetSourceData objRange, xlColumns
     
     
    End Sub
    Ou :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
     
    Dim objChart As Chart, objRange As Range
     
        Set objRange = Worksheets("Feuil1").Range(Worksheets("Feuil1").Cells(1, 1), Worksheets("Feuil1").Cells(21, 3))
        Set objChart = ThisWorkbook.Charts.Add
        objChart.ChartType = xlXYScatter
        objChart.SeriesCollection.Add objRange, xlColumns, True, True
    Quelles sont les modifs que je dois faire pour avoir cet état là ?.

    Edit : La courbe doit être en D2
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

  2. #2
    Expert éminent sénior Avatar de mercatog
    Homme Profil pro
    Inscrit en
    Juillet 2008
    Messages
    9 435
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations forums :
    Inscription : Juillet 2008
    Messages : 9 435
    Points : 31 877
    Points
    31 877
    Par défaut
    Bonjour,
    ajoute
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objChart.Location Where:=xlLocationAsObject, Name:="MonGraphique"
    Cordialement.
    J'utilise toujours le point comme séparateur décimal dans mes tests.

  3. #3
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut
    Citation Envoyé par mercatog Voir le message
    Bonjour,
    ajoute
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    objChart.Location Where:=xlLocationAsObject, Name:="MonGraphique"
    Marche pas .
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

  4. #4
    Expert éminent sénior Avatar de mercatog
    Homme Profil pro
    Inscrit en
    Juillet 2008
    Messages
    9 435
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations forums :
    Inscription : Juillet 2008
    Messages : 9 435
    Points : 31 877
    Points
    31 877
    Par défaut
    As tu adapté?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Dim objChart As Chart, objRange As Range
    Set objRange = Worksheets("Feuil1").Range(Worksheets("Feuil1").Cells(1, 1), Worksheets("Feuil1").Cells(21, 3))
    Set objChart = ThisWorkbook.Charts.Add
    objChart.ChartType = xlXYScatter
    objChart.SeriesCollection.Add objRange, xlColumns, True, True
    objChart.Location Where:=xlLocationAsObject, Name:="Feuil1"
    tu dis?
    Cordialement.
    J'utilise toujours le point comme séparateur décimal dans mes tests.

  5. #5
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut
    ça marche .

    A cause de ça au lieu de Par contre, sur mes abscisses, la date n'est pas triée par ordre de croissance, il l'affiche au pif .
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

  6. #6
    Expert éminent sénior Avatar de mercatog
    Homme Profil pro
    Inscrit en
    Juillet 2008
    Messages
    9 435
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Autre

    Informations forums :
    Inscription : Juillet 2008
    Messages : 9 435
    Points : 31 877
    Points
    31 877
    Par défaut
    C'est une autre question
    tu es sur de tes données sont des dates?
    et si tu faisais le graphe manuellement, le résultat est convenable?
    Cordialement.
    J'utilise toujours le point comme séparateur décimal dans mes tests.

  7. #7
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut
    Oui j'en suis sur, le format des cellules est de type date et le résultat est convenable manuellement.

    Edit : Une toute dernière contrainte à ajouter, je veux que le graphe sois dynamique, qu'il tienne en compte toutes les modifs sur mon tableau, comme ça, j'aurai juste un document générique à adapter .
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

  8. #8
    Membre confirmé Avatar de _shuriken_
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    543
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39

    Informations professionnelles :
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2006
    Messages : 543
    Points : 454
    Points
    454
    Par défaut
    Pour l'update automatique du graphe, se référer à ce topic.
    "When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarcely in your thoughts advanced to the state of Science, whatever the matter may be."

    Lord Kelvin - 1883.

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

Discussions similaires

  1. imprimer plusieures zones d'impression sur la même feuille
    Par gratesnif dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 15/10/2007, 15h05
  2. problème de changement sur une même feuille
    Par tchimou dans le forum Delphi
    Réponses: 4
    Dernier message: 03/04/2007, 14h39
  3. Affichage de plusieurs graphiques sur une même form
    Par redpulse dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 02/02/2007, 09h41
  4. Réponses: 2
    Dernier message: 29/11/2006, 12h52
  5. Imprimer toutes les colonnes sur une même feuille
    Par Soulghard dans le forum Access
    Réponses: 1
    Dernier message: 02/02/2006, 13h10

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