Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Coabitation macros

5 réponses
Avatar
Jol
Bonjour,

J'ai dans une feuille les deux macros suivantes :
'''Date Création enregistrement
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
End Sub

''' Forçer Majuscule
Private Sub Worksheet_Change(ByVal zz As Range)
If Intersect(zz, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
zz = UCase(zz)
Application.EnableEvents = True
End Sub

l'une inscrit la date de saisie, l'autre force l'enregistrement en Maj.

L'erreur suivante apparait : "Erreur de compilation : Nom ambiguë détecté
(Worksheet_Change).
je pense comprendre pourquoi mais ne sais pas y remédier...

Merci

5 réponses

Avatar
FFO
Salut à toi

Mets les codes ensembles ainsi :


Private Sub Worksheet_Change(ByVal Target As Range,ByVal zz As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count =
1 Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
If Intersect(zz, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
zz = UCase(zz)
Application.EnableEvents = True
End Sub

Celà devrait faire

Fais des essais et dis moi !!!!
Avatar
MichD
Bonjour,

Tu ne peux pas avoir 2 macros événementielles identiques dans le même module

Combine le code de tes 2 macros comme ceci :

'---------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
If Intersect(Target, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True

End Sub
'---------------------------------


MichD
--------------------------------------------
"Jol" a écrit dans le message de groupe de discussion : iqjdcq$nmo$

Bonjour,

J'ai dans une feuille les deux macros suivantes :
'''Date Création enregistrement
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
End Sub

''' Forçer Majuscule
Private Sub Worksheet_Change(ByVal zz As Range)
If Intersect(zz, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
zz = UCase(zz)
Application.EnableEvents = True
End Sub

l'une inscrit la date de saisie, l'autre force l'enregistrement en Maj.

L'erreur suivante apparait : "Erreur de compilation : Nom ambiguë détecté
(Worksheet_Change).
je pense comprendre pourquoi mais ne sais pas y remédier...

Merci
Avatar
Jol
Merci à vous deux,

MichD, ta macro fonctionne parfaitement à ceci près que si je supprime une
ligne dans ma table j'ai un erreur d'exécution 13 et bien sûr la macro ne
foctionne plus.

Pour FFO ça ne fonctionne pas...


"MichD" a écrit dans le message de
news:iqjf84$vdl$
Bonjour,

Tu ne peux pas avoir 2 macros événementielles identiques dans le même
module

Combine le code de tes 2 macros comme ceci :

'---------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
If Intersect(Target, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True

End Sub
'---------------------------------


MichD
--------------------------------------------
"Jol" a écrit dans le message de groupe de discussion :
iqjdcq$nmo$

Bonjour,

J'ai dans une feuille les deux macros suivantes :
'''Date Création enregistrement
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1
Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
End Sub

''' Forçer Majuscule
Private Sub Worksheet_Change(ByVal zz As Range)
If Intersect(zz, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
zz = UCase(zz)
Application.EnableEvents = True
End Sub

l'une inscrit la date de saisie, l'autre force l'enregistrement en Maj.

L'erreur suivante apparait : "Erreur de compilation : Nom ambiguë détecté
(Worksheet_Change).
je pense comprendre pourquoi mais ne sais pas y remédier...

Merci

Avatar
MichD
Essaie comme ceci :

Je n'avais fait que transcrire et combiner les 2 macros
;-)

'----------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rg As Range, C As Range
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If

Set Rg = Intersect(Target, [a2:I6000])
If Not Rg Is Nothing Then
Application.EnableEvents = False
For Each C In Rg
If Not IsEmpty(C) Then
C = UCase(C)
End If
Next
Application.EnableEvents = True
End If
End Sub
'----------------------------------


MichD
--------------------------------------------
"Jol" a écrit dans le message de groupe de discussion : iqji6t$ca2$

Merci à vous deux,

MichD, ta macro fonctionne parfaitement à ceci près que si je supprime une
ligne dans ma table j'ai un erreur d'exécution 13 et bien sûr la macro ne
foctionne plus.

Pour FFO ça ne fonctionne pas...


"MichD" a écrit dans le message de
news:iqjf84$vdl$
Bonjour,

Tu ne peux pas avoir 2 macros événementielles identiques dans le même
module

Combine le code de tes 2 macros comme ceci :

'---------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
If Intersect(Target, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True

End Sub
'---------------------------------


MichD
--------------------------------------------
"Jol" a écrit dans le message de groupe de discussion :
iqjdcq$nmo$

Bonjour,

J'ai dans une feuille les deux macros suivantes :
'''Date Création enregistrement
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1
Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
End Sub

''' Forçer Majuscule
Private Sub Worksheet_Change(ByVal zz As Range)
If Intersect(zz, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
zz = UCase(zz)
Application.EnableEvents = True
End Sub

l'une inscrit la date de saisie, l'autre force l'enregistrement en Maj.

L'erreur suivante apparait : "Erreur de compilation : Nom ambiguë détecté
(Worksheet_Change).
je pense comprendre pourquoi mais ne sais pas y remédier...

Merci

Avatar
Jol
En te remerciant MichD, c'est parfait.

"Jol" a écrit dans le message de
news:iqjdcq$nmo$
Bonjour,

J'ai dans une feuille les deux macros suivantes :
'''Date Création enregistrement
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect([A2:A65000], Target) Is Nothing And Target.Count = 1
Then
Application.EnableEvents = False
Target.Offset(0, 9) = Now
Application.EnableEvents = True
End If
End Sub

''' Forçer Majuscule
Private Sub Worksheet_Change(ByVal zz As Range)
If Intersect(zz, [a2:I6000]) Is Nothing Then Exit Sub
Application.EnableEvents = False
zz = UCase(zz)
Application.EnableEvents = True
End Sub

l'une inscrit la date de saisie, l'autre force l'enregistrement en Maj.

L'erreur suivante apparait : "Erreur de compilation : Nom ambiguë détecté
(Worksheet_Change).
je pense comprendre pourquoi mais ne sais pas y remédier...

Merci