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 :

Erreur d'exécution 91 variable objet ou variable de bloc with non définie


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Enseignant en Activité Physique Adaptée
    Inscrit en
    Août 2021
    Messages
    25
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Enseignant en Activité Physique Adaptée
    Secteur : Santé

    Informations forums :
    Inscription : Août 2021
    Messages : 25
    Par défaut Erreur d'exécution 91 variable objet ou variable de bloc with non définie
    Bonjour tout le monde,

    j'utilise une macro VBA afin d'afficher des données dans des graphiques.

    J'ai un jeu de données qui va de la colonne B à la colonne U. Les valeurs que je souhaite afficher sont à la ligne 10 et 11.

    Je souhaite créé une série de donnée "amélioration" qui concerne les données dans la ligne 10 et une série "dégradation" qui concerne les données dans la ligne 11.

    J'ai 9 checkbox qui vont me permettre de choisir les colonnes à afficher dans mes graphiques (chaque colonne correspond à un test effectué par des participants), les checkbox sont associées à certaines colonnes pour me permettre d'afficher plusieurs résultats en même temps en les sélectionnant à l'avance.

    La macro identifie bien les colonnes à afficher en fonction des checkbox cochées (sauf la checkbox2 qui ne fonctionne pas). La série1 ("zone1") et ma série 2 '"zone2") sont bien créées mais aux lignes :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ActiveChart.FullSeriesCollection(1).values = Range("'AméliorationDégradation Indiv'!" & zone)
    ActiveChart.FullSeriesCollection(2).values = Range("'AméliorationDégradation Indiv'!" & zone2)
    J'ai l'erreur : Erreur d'exécution 91 variable objet ou variable de bloc with non définie

    Pouvez-vous m'aider ?

    Voici 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
    Sub graph01_b()
    'Dim CheckBox1 As MSForms.CheckBox, CheckBox2 As MSForms.CheckBox, CheckBox3 As MSForms.CheckBox, CheckBox4 As MSForms.CheckBox, CheckBox5 As MSForms.CheckBox, CheckBox6 As MSForms.CheckBox, CheckBox7 As MSForms.CheckBox, CheckBox8 As MSForms.CheckBox, CheckBox9 As MSForms.CheckBox
     
        'Identifier les colonnes en encodant 0 ou 1 (1=colonne choisie; 0 = colonne ignorée) sur 1 ligne de votre choix
    'souplesse
        If CheckBox1 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 2) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 3) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 4) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 5) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 2) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 3) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 4) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 5) = 0
        End If
        'ne fonctionne pas score détaillé sppb
        If CheckBox2 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 6) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 10) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 11) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 12) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 13) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 20) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 6) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 10) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 11) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 12) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 13) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 20) = 0
        End If
        'score sppb
        If CheckBox3 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 6) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 10) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 11) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 12) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 13) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 20) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 6) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 10) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 11) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 12) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 13) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 20) = 0
        End If
        'test de 10m
        If CheckBox4 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 9) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 9) = 0
        End If
        'Time stand test 10 fois
        If CheckBox5 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 14) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 14) = 0
        End If
        'unipodal
        If CheckBox6 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 15) = 1
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 16) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 15) = 0
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 16) = 0
        End If
        'TUG
        If CheckBox7 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 17) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 17) = 0
        End If
        'nombre de chute
        If CheckBox8 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 18) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 18) = 0
        End If
        'vitesse de marche
        If CheckBox9 = True Then
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 21) = 1
        Else
            ThisWorkbook.Sheets("AméliorationDégradation Indiv").Cells(20, 21) = 0
        End If
     
     
        Dim zone   As String
        Dim zone2   As String
        Dim j      As Integer
        Dim c      As Range
     
        With ThisWorkbook.Sheets("AméliorationDégradation Indiv")
            For j = 2 To 21                           'colonnes B à U
                If .Cells(20, j) = 1 Then zone = zone & ", " & .Cells(10, j).Address '0 et 1 sont encodés en ligne 20
                If .Cells(20, j) = 1 Then zone2 = zone2 & ", " & .Cells(11, j).Address
            Next j
        End With
     
        If Left(zone, 2) = ", " Then zone = Mid(zone, 3)
        If Left(zone2, 2) = ", " Then zone2 = Mid(zone2, 3)
     
        'MsgBox zone
        'MsgBox zone2
     
     
     
    ActiveChart.FullSeriesCollection(1).values = Range("'AméliorationDégradation Indiv'!" & zone)
    ActiveChart.FullSeriesCollection(2).values = Range("'AméliorationDégradation Indiv'!" & zone2)
     
    End Sub
    Quand je coche les checkbox 1 et 3 dans les variables locales j'ai :
    : zone : "$B$10, $C$10, $D$10, $E$10, $T$10" : String
    : zone2 : "$B$11, $C$11, $D$11, $E$11, $T$11" : String

    Donc les cellules sont bien identifiées mais j'ai l'erreur au moment de créer les graphiques :
    ActiveChart.FullSeriesCollection(1).values = Range("'AméliorationDégradation Indiv'!" & zone)
    ActiveChart.FullSeriesCollection(2).values = Range("'AméliorationDégradation Indiv'!" & zone2)

    Pouvez-vous m'aider svp ?

    Merci à vous !

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    1 554
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 1 554
    Par défaut
    je remplacerai tes lignes par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ActiveChart.FullSeriesCollection(1).values = ThisWorkbook.Sheets("AméliorationDégradation Indiv").Range(zone)
    ActiveChart.FullSeriesCollection(2).values = ThisWorkbook.Sheets("AméliorationDégradation Indiv").Range(zone2)

Discussions similaires

  1. Réponses: 14
    Dernier message: 23/05/2016, 14h05
  2. erreur d'exécution 91 variable objet ou variable de bloc with non définie
    Par ramo123469 dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 01/04/2016, 14h55
  3. [XL-2013] erreur d'exécution 91 variable objet ou variable de bloc with non définie
    Par tmlpqsdpmdlc dans le forum Macros et VBA Excel
    Réponses: 18
    Dernier message: 08/06/2015, 13h25
  4. Réponses: 6
    Dernier message: 24/02/2015, 09h06
  5. Réponses: 4
    Dernier message: 24/05/2014, 19h24

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