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 :

nom ambigu détecté : worksheet change


Sujet :

Macros et VBA Excel

  1. #1
    Nouveau Candidat au Club
    Inscrit en
    Février 2011
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 3
    Points : 1
    Points
    1
    Par défaut nom ambigu détecté : worksheet change
    sur une page j'ai 2 instructions et je suis en conflit le message nom ambigu détecté : worksheet change apparaît . Est-il
    possible de les réunir ?


    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
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim isect As Range
    Dim n As String, commentaire As String
    Dim c As Range
    Set isect = Application.Intersect(Target, Range("c8:c33"))
    If isect Is Nothing Then
        Exit Sub
    Else
    n = ActiveCell.Value
    For Each c In Range("b101:b164")
    If c.Value = n Then
    commentaire = c.Offset(0, 1).Value
    End If
    Next c
    ActiveCell.ClearComments
    ActiveCell.AddComment
    ActiveCell.Comment.Text Text:=commentaire
    End If
    End Sub
     
    Private Sub Worksheet_SelectChange(ByVal Target As Range)
    Dim isect As Range
    Dim n As String, commentaire As String
    Dim c As Range
    Set isect = Application.Intersect(Target, Range("e8:e33"))
    If isect Is Nothing Then
        Exit Sub
    Else
    n = ActiveCell.Value
    For Each c In Range("d101:d110")
    If c.Value = n Then
    commentaire = c.Offset(0, 1).Value
    End If
    Next c
    ActiveCell.ClearComments
    ActiveCell.AddComment
    ActiveCell.Comment.Text Text:=commentaire
    End If
    End Sub

  2. #2
    Expert éminent
    Avatar de Didier Gonard
    Homme Profil pro
    Formateur Office et développeur VBA en freelance
    Inscrit en
    Février 2008
    Messages
    2 805
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Formateur Office et développeur VBA en freelance

    Informations forums :
    Inscription : Février 2008
    Messages : 2 805
    Points : 6 699
    Points
    6 699
    Par défaut
    Bonjour,

    Il vient d'où cet évènementiel ?

    Private Sub Worksheet_SelectChange(ByVal Target As Range)
    Dans le module Feuille, voilà ce qui existe...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     
    End Sub
    cordialement,

    Didier

  3. #3
    Nouveau Candidat au Club
    Inscrit en
    Février 2011
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    désolé je me suis tromper

    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
    option Explicit
     
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim isect As Range
    Dim n As String, commentaire As String
    Dim c As Range
    Set isect = Application.Intersect(Target, Range("c8:c33"))
    If isect Is Nothing Then
        Exit Sub
    Else
    n = ActiveCell.Value
    For Each c In Range("b101:b164")
    If c.Value = n Then
    commentaire = c.Offset(0, 1).Value
    End If
    Next c
    ActiveCell.ClearComments
    ActiveCell.AddComment
    ActiveCell.Comment.Text Text:=commentaire
    End If
    End Sub
     
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim isect As Range
    Dim n As String, commentaire As String
    Dim c As Range
    Set isect = Application.Intersect(Target, Range("e8:e33"))
    If isect Is Nothing Then
        Exit Sub
    Else
    n = ActiveCell.Value
    For Each c In Range("d101:d110")
    If c.Value = n Then
    commentaire = c.Offset(0, 1).Value
    End If
    Next c
    ActiveCell.ClearComments
    ActiveCell.AddComment
    ActiveCell.Comment.Text Text:=commentaire
    End If
    End Sub

  4. #4
    Expert éminent
    Avatar de Didier Gonard
    Homme Profil pro
    Formateur Office et développeur VBA en freelance
    Inscrit en
    Février 2008
    Messages
    2 805
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Formateur Office et développeur VBA en freelance

    Informations forums :
    Inscription : Février 2008
    Messages : 2 805
    Points : 6 699
    Points
    6 699
    Par défaut
    Si, comme le code donné le suggère, il y a 2 procédures Worksheet_Change dans le même module Feuille, c'est normal que VBA réagisse, c'est interdit

    Quand l"évènement va se produire, quelle procédure devrait-il prendre ?

    voir ceci :

    Les évènements dans la feuille de calcul Excel

    cordialement,

    Didier

  5. #5
    Nouveau Candidat au Club
    Inscrit en
    Février 2011
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 3
    Points : 1
    Points
    1
    Par défaut
    je veux les assemblés comment ca se fait

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Février 2006
    Messages
    288
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 288
    Points : 364
    Points
    364
    Par défaut
    Bonjour,
    à ce moment là il faut réunir les conditions dans le même événement Worksheet_Change :

    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
    Option Explicit
     
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim isect As Range
    Dim n As String, commentaire As String
    Dim c As Range
     
    If Not Intersect(Target, Range("c8:c33")) Is Nothing Then
        n = ActiveCell.Value
        For Each c In Range("b101:b164")
            If c.Value = n Then
                commentaire = c.Offset(0, 1).Value
            End If
        Next c
     
        ActiveCell.ClearComments
        ActiveCell.AddComment
        ActiveCell.Comment.Text Text:=commentaire
     
    ElseIf Not Intersect(Target, Range("e8:e33")) Is Nothing Then
        n = ActiveCell.Value
        For Each c In Range("d101:d110")
            If c.Value = n Then
                commentaire = c.Offset(0, 1).Value
            End If
        Next c
     
        ActiveCell.ClearComments
        ActiveCell.AddComment
        ActiveCell.Comment.Text Text:=commentaire
     
    Else
        Exit Sub
    End If
     
    End Sub

Discussions similaires

  1. [XL-2003] "Erreur de compilation, nom ambigu détecté worksheet change". :/
    Par Imperium dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 23/09/2021, 14h36
  2. Problème : nom ambigu détecté : ComboBox1_change
    Par eleanor62200 dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 28/04/2011, 09h12
  3. [XL-2003] Nom ambigu détecté
    Par Tonete dans le forum Macros et VBA Excel
    Réponses: 6
    Dernier message: 26/11/2010, 20h49
  4. Evènement Worksheet Change
    Par elise__ dans le forum Macros et VBA Excel
    Réponses: 6
    Dernier message: 26/10/2007, 14h36
  5. evenement worksheets change
    Par AnozerOne dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 06/07/2007, 06h42

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