Beug dans un code

Bonjour

J'ai un problème dans un code VBA

Sur une même feuille j'ai ce code le premier code fonctionne bien seul

Le deuxième également les 2 associés forment un beug avec les lignes Private Sub

Comment résoudre le problème pour que tout cela fonctionne

Je vous remercie

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Range("C2:I65"), Target) Is Nothing And Target <> "" Then
Application.EnableEvents = False
Target = Application.Proper(Target)
Application.EnableEvents = True
End If
End Sub

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim tablo As Range
Dim nom$, nomI$
Set tablo = Range("B1").CurrentRegion
If Not Intersect(Target, tablo) Is Nothing _
And (Target.Column = 3 Or Target.Column = 5 _
Or Target.Column = 7 Or Target.Column = 9) Then
Application.EnableEvents = False
nom = Target.Value
If Target.Value = "" Then GoTo fin
Application.Undo
nomI = ActiveCell.Value
If nomI <> "" Then GoTo fin
Target.Value = Target.Offset(0, -1) & " " & nom
End If
fin:
Application.EnableEvents = True

End Sub

Sub Evenement()
Application.EnableEvents = True
End Sub

Salut Joco,

tu ne peux avoir DEUX Private Sub Worksheet_Change !!
Il faut faire en sorte de coder dans la MÊME sub !!


A+

Bonjour curulis 57

Merci pour ta réponse

Je me doutais bien de ce souci des 2 Private Sub Worksheet_Change

Le hic c'est que je n'arrive pas a faire la modif,d’où ma demande.

Salut Joco,

de ce que j'ai compris...

Private Sub Worksheet_Change(ByVal Target As Range)
'
If Target.Count > 1 Or Target = "" Then Exit Sub
Application.EnableEvents = False
'
If Not Intersect(Target, Range("C2:I65")) Is Nothing Then
    Target = Application.Proper(Target)
    '
    If Target.Column = 3 Or Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Then _
        Target = Target.Offset(0, -1) & " " & Target
End If
'
Application.EnableEvents = True
'
End Sub


A+

Rechercher des sujets similaires à "beug code"