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 :

Run time error 1004 - Select method class failed


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 5
    Par défaut Run time error 1004 - Select method class failed
    Bonjour,

    j'ai un petit soucis récurrent : lorsque je veux sélectionner une cellule d'une feuille de travail autre que celle dans laquelle j'effectue mon code, l'erreur 1004 Select method class failed apparait. Plus précisémment, c'est mon Range ("X").Select qui pose problème. Quelqu'un pourrait il m'aider ?

  2. #2
    Membre expérimenté Avatar de ilcocodrillo
    Profil pro
    Inscrit en
    Février 2007
    Messages
    260
    Détails du profil
    Informations personnelles :
    Âge : 18
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 260
    Par défaut
    t'aurais un bout de code ? par ce que là franchement c'est un poil court pour t'aider...

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 5
    Par défaut
    Voici mon code :

    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
    Range("B1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Range("A1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
            "'Extract GP3'!R1C1:R21195C7").CreatePivotTable TableDestination:="", _
            TableName:="PivotTable3", DefaultVersion:=xlPivotTableVersion10
        ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
        ActiveSheet.Cells(3, 1).Select
        With ActiveSheet.PivotTables("PivotTable3").PivotFields("Code compart")
            .Orientation = xlRowField
            .Position = 1
        End With
        With ActiveSheet.PivotTables("PivotTable3").PivotFields("Des compart")
            .Orientation = xlRowField
            .Position = 2
        End With
        With ActiveSheet.PivotTables("PivotTable3").PivotFields("Account n°")
            .Orientation = xlRowField
            .Position = 3
        End With
        ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
            "PivotTable3").PivotFields("Debit"), "Sum of Debit", xlSum
        ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
            "PivotTable3").PivotFields("Credit"), "Sum of Credit", xlSum
        Range("D3").Select    With ActiveSheet.PivotTables("PivotTable3").DataPivotField
            .Orientation = xlColumnField
            .Position = 1
        End With
        ActiveWindow.ScrollRow = 86
        ActiveWindow.ScrollRow = 171
        ActiveWindow.ScrollRow = 256
        ActiveSheet.PivotTables("PivotTable3").PivotSelect "'Code compart'[All;Total]" _
            , xlDataAndLabel, True
        Selection.Delete
        Range("B262").Select
        Selection.Delete
    Le message d'erreur apparait sur la ligne Rnage ("D3"). Select

  4. #4
    Membre expérimenté Avatar de ilcocodrillo
    Profil pro
    Inscrit en
    Février 2007
    Messages
    260
    Détails du profil
    Informations personnelles :
    Âge : 18
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 260
    Par défaut
    1 ) utilise les balise CODE !

    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
     
    'Range("B1").Select
    'Range(Selection, Selection.End(xlToRight)).Select
    'Range(Selection, Selection.End(xlDown)).Select
    'Range("A1").Select
    'Range(Selection, Selection.End(xlToRight)).Select
    'Range(Selection, Selection.End(xlDown)).Select
    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    "'Extract GP3'!R1C1:R21195C7").CreatePivotTable TableDestination:="", _
    TableName:="PivotTable3", DefaultVersion:=xlPivotTableVersion10
    ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
    'ActiveSheet.Cells(3, 1).Select
    With ActiveSheet.PivotTables("PivotTable3").PivotFields("Code compart")
    .Orientation = xlRowField
    .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable3").PivotFields("Des compart")
    .Orientation = xlRowField
    .Position = 2
    End With
    With ActiveSheet.PivotTables("PivotTable3").PivotFields("Account n°")
    .Orientation = xlRowField
    .Position = 3
    End With
    ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
    "PivotTable3").PivotFields("Debit"), "Sum of Debit", xlSum
    ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
    "PivotTable3").PivotFields("Credit"), "Sum of Credit", xlSum
    'Range("D3").Select
     
    ' il y a au moins déjà ça qui ne pouvait pas fonctionner
     
     With ActiveSheet.PivotTables("PivotTable3").DataPivotField
    .Orientation = xlColumnField
    .Position = 1
    End With
     
    ''ça sert à rien
    'ActiveWindow.ScrollRow = 86
    'ActiveWindow.ScrollRow = 171
    'ActiveWindow.ScrollRow = 256
    ActiveSheet.PivotTables("PivotTable3").PivotSelect "'Code compart'[All;Total]" _
    , xlDataAndLabel, True
    Selection.Delete
    Range("B262").Select
    Selection.Delete
    Mais il y a pas mal de ligne qui ne servent à rien dans ton code ... a commencer par les six premières...

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    5
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 5
    Par défaut
    OK, résolu. Merci beaucoup

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

Discussions similaires

  1. [XL-2010] Run time error 1004 Application defined or object defined
    Par AmbreM dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 19/09/2013, 18h00
  2. Run-time error '1004'
    Par byran444 dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 10/12/2012, 11h19
  3. Excel 2003 - Run-time error '1004'
    Par GuyRo dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 08/05/2008, 10h20
  4. [VBA-E] Run-time error 1004, pourquoi ?
    Par Capsule dans le forum Macros et VBA Excel
    Réponses: 18
    Dernier message: 25/01/2007, 22h12
  5. Excel - macro (format conditionnel - run-time error 1004)
    Par Chewi dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 01/09/2006, 19h18

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