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 :

Selection.Copy Erreur de comilation Fonction ou variable attendue


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Mai 2012
    Messages
    1 150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mai 2012
    Messages : 1 150
    Par défaut Selection.Copy Erreur de comilation Fonction ou variable attendue
    Bonjour, alors là je sèche,
    J'ai utilisé un code toute la journée hier toute pour copier des valeurs dans des cellules pour les utiliser après sur des pages web.
    Aujourd'hui, je copie / colle dans un autre fichier, première utilisation ok, je modifie plus bas dans le code et la plantage ?????

    L'ancien code (OK):

    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
     
    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Column <> 2 And Target.Count = 1 Then
    Selection.Copy
    End If
     
    Dim STATUT As Variant, LigDEB As Double, LigFIN As Double
    If Target.Column = 2 Then
     
     
     
    STATUT = InputBox("STATUT: 0 = Debut de traitement / 1 = En cours de traiement  / 2 = Traitement accompli", "STATUT: 0 = Debut de traitement / 1 = En cours de traiement  / 2 = Traitement accompli")
     
     
    LigDEB = Selection.Row & vbNewLine
    LigFIN = Selection.Rows.Count - 1 + Selection.Row
     
     
     
     
    Select Case STATUT
     
     
     
    Case Is = 0
     
    Rows(LigDEB & ":" & LigFIN).Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 14540287
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
     
     
    Case Is = 1
     
    Rows(LigDEB & ":" & LigFIN).Select
     
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 49407
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
     
        Case Is = 2
     
    Rows(LigDEB & ":" & LigFIN).Select
     
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorDark1
            .TintAndShade = -0.499984740745262
            .PatternTintAndShade = 0
        End With
     
      ActiveWorkbook.Save
     
     
     
    Case Is > 2
     
    Exit Sub
     
     
        Case Is = ""
     
    Exit Sub
     
    Case Is = False
     
    Exit Sub
     
    End Select
     
    End If
    End Sub
    Code modifié:

    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
     
    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Column <> 2 And Target.Count = 1 Then
    Selection.Copy
    End If
     
    Dim STATUT As Variant, LigDEB As Double, LigFIN As Double
    If Target.Column = 2 Then
     
     
     
    STATUT = InputBox("STATUT: 0 = Debut de traitement / 1 = En cours de traiement  / 2 = Traitement accompli", "STATUT: 0 = Debut de traitement / 1 = En cours de traiement  / 2 = Traitement accompli")
     
     
    LigDEB = Selection.Row & vbNewLine
    LigFIN = Selection.Rows.Count - 1 + Selection.Row
     
     
    Cells(LigDEB, 1).Select
     
    Exit Sub
     
     
     
    Select Case STATUT
     
     
     
    Case Is = 0
     
     
    Range(Cells(LigDEB, 3), Cells(LigFIN, 8)).Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 14540287
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
     
     
    Case Is = 1
     
     
    Range(Cells(LigDEB, 3), Cells(LigFIN, 8)).Select
     
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 49407
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
     
        Case Is = 2
     
    Range(Cells(LigDEB, 3), Cells(LigFIN, 8)).Select
     
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorDark1
            .TintAndShade = -0.499984740745262
            .PatternTintAndShade = 0
        End With
     
      ActiveWorkbook.Save
     
     
     
    Case Is > 2
     
    Exit Sub
     
     
        Case Is = ""
     
    Exit Sub
     
    Case Is = False
     
    Exit Sub
     
    End Select
     
    End If
    End Sub
    Excel ne veut pas entendre parler de et plante dès le premier , si je le supprime, sur , retour d'erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Erreur de comilation Fonction ou variable attendue
    .

    Merci beaucoup pour vos aides, je n'y comprends rien là

  2. #2
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Mai 2012
    Messages
    1 150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mai 2012
    Messages : 1 150
    Par défaut
    Et l'ancien code plante aussi

  3. #3
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Mai 2012
    Messages
    1 150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mai 2012
    Messages : 1 150
    Par défaut
    Trouvé:
    J'ai intitulé une autre macro "Selection".......

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

Discussions similaires

  1. Fonction ou variable attendue!
    Par zakou76 dans le forum Macros et VBA Excel
    Réponses: 11
    Dernier message: 16/03/2019, 21h05
  2. [AC-2010] Erreur de compilation : Fonction ou variable attendue
    Par Plantakwatix dans le forum VBA Access
    Réponses: 1
    Dernier message: 08/03/2013, 14h43
  3. Erreur de la fonction Copy, dans la bibliotheque ipp
    Par MPEG4 dans le forum Bibliothèques
    Réponses: 0
    Dernier message: 24/07/2009, 18h23
  4. erreur : Fonction ou variable attendue
    Par veer2006 dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 29/07/2007, 20h23
  5. faire une selection multiple de feuilles en fonction de variables
    Par blackhelmet dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 18/10/2006, 10h32

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