J'ai déjà une macro dans l'onglet dans l'onglet en question pour mettre en
caratère rouge, tout changement que l'opérateur fais un faisant un retour de
chariot. J'aimerais rajouter une autre macro qui lance un avertissement
suivante:
J'ai deux colonnes, BC et BD.
Quand l'utilisateur entre un montant dans BD, il ne doit jamais dépasser le
montant de BC.
Faire afficher le message:
MsgBox "Le montant est supérieur à vos disponibilités."
Dans mon chose de validation, j'ai déjà une autre fonction.
Voici ma macro actuelle de l'onglet:
____________________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect Password:="Reg" '__________désactive la protection
If Target.Count > 1 Then Exit Sub
Set isect1 = Application.Intersect(Target, Range("A17:BJ90"))
Set isect2 = Application.Intersect(Target, Range("A96:BJ141"))
Set isect3 = Application.Intersect(Target, Range("A146:BJ166"))
Set isect4 = Application.Intersect(Target, Range("A172:BJ209"))
'____________
If Not isect1 Is Nothing Or Not isect2 Is Nothing Or Not isect3 Is _
Nothing _
Or Not isect4 Is Nothing Then Target.Font.ColorIndex = 3
'_________________
If Target.Column <> 56 Then Exit Sub
If Not IsNumeric(Target.Value) Then Exit Sub
Target.Offset(0, 1).Value = Target.Offset(0, 1).Value + Target.Value
ActiveSheet.Protect Password:="Reg" '______________ l'active
End Sub
____________________________________________________________
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Daniel
Bonsoir. essaie (non testé) :
Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.Unprotect Password:="Reg" '__________désactive la protection If Target.Count > 1 Then Exit Sub Set isect1 = Application.Intersect(Target, Range("A17:BJ90")) Set isect2 = Application.Intersect(Target, Range("A96:BJ141")) Set isect3 = Application.Intersect(Target, Range("A146:BJ166")) Set isect4 = Application.Intersect(Target, Range("A172:BJ209")) '____________
If Not Intersect(Target, Range("BD:BD")) Is Nothing Then If Target > Target(0, -1) Then MsgBox "Le montant est supérieur à vos disponibilités." End If ElseIf Not isect1 Is Nothing Or Not isect2 Is Nothing Or Not isect3 Is _ Nothing _ Or Not isect4 Is Nothing Then Target.Font.ColorIndex = 3 '_________________ If Target.Column <> 56 Then Exit Sub If Not IsNumeric(Target.Value) Then Exit Sub Target.Offset(0, 1).Value = Target.Offset(0, 1).Value + Target.Value ActiveSheet.Protect Password:="Reg" '______________ l'active End Sub
Cordialement. Daniel "Érico" a écrit dans le message de news: u$
Bonjour à tous,
J'ai déjà une macro dans l'onglet dans l'onglet en question pour mettre en caratère rouge, tout changement que l'opérateur fais un faisant un retour de chariot. J'aimerais rajouter une autre macro qui lance un avertissement suivante:
J'ai deux colonnes, BC et BD.
Quand l'utilisateur entre un montant dans BD, il ne doit jamais dépasser le montant de BC. Faire afficher le message: MsgBox "Le montant est supérieur à vos disponibilités."
Dans mon chose de validation, j'ai déjà une autre fonction.
Voici ma macro actuelle de l'onglet: ____________________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.Unprotect Password:="Reg" '__________désactive la protection If Target.Count > 1 Then Exit Sub Set isect1 = Application.Intersect(Target, Range("A17:BJ90")) Set isect2 = Application.Intersect(Target, Range("A96:BJ141")) Set isect3 = Application.Intersect(Target, Range("A146:BJ166")) Set isect4 = Application.Intersect(Target, Range("A172:BJ209")) '____________
If Not isect1 Is Nothing Or Not isect2 Is Nothing Or Not isect3 Is _ Nothing _ Or Not isect4 Is Nothing Then Target.Font.ColorIndex = 3 '_________________ If Target.Column <> 56 Then Exit Sub If Not IsNumeric(Target.Value) Then Exit Sub Target.Offset(0, 1).Value = Target.Offset(0, 1).Value + Target.Value ActiveSheet.Protect Password:="Reg" '______________ l'active End Sub ____________________________________________________________
Merci a vous tous de votre collaboration.
Érico de montréal
Bonsoir.
essaie (non testé) :
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect Password:="Reg" '__________désactive la protection
If Target.Count > 1 Then Exit Sub
Set isect1 = Application.Intersect(Target, Range("A17:BJ90"))
Set isect2 = Application.Intersect(Target, Range("A96:BJ141"))
Set isect3 = Application.Intersect(Target, Range("A146:BJ166"))
Set isect4 = Application.Intersect(Target, Range("A172:BJ209"))
'____________
If Not Intersect(Target, Range("BD:BD")) Is Nothing Then
If Target > Target(0, -1) Then
MsgBox "Le montant est supérieur à vos disponibilités."
End If
ElseIf Not isect1 Is Nothing Or Not isect2 Is Nothing Or Not isect3 Is _
Nothing _
Or Not isect4 Is Nothing Then Target.Font.ColorIndex = 3
'_________________
If Target.Column <> 56 Then Exit Sub
If Not IsNumeric(Target.Value) Then Exit Sub
Target.Offset(0, 1).Value = Target.Offset(0, 1).Value + Target.Value
ActiveSheet.Protect Password:="Reg" '______________ l'active
End Sub
Cordialement.
Daniel
"Érico" <hahaha@videotron.ca> a écrit dans le message de news:
u$6UYhuTHHA.5060@TK2MSFTNGP06.phx.gbl...
Bonjour à tous,
J'ai déjà une macro dans l'onglet dans l'onglet en question pour mettre en
caratère rouge, tout changement que l'opérateur fais un faisant un retour
de chariot. J'aimerais rajouter une autre macro qui lance un avertissement
suivante:
J'ai deux colonnes, BC et BD.
Quand l'utilisateur entre un montant dans BD, il ne doit jamais dépasser
le montant de BC.
Faire afficher le message:
MsgBox "Le montant est supérieur à vos disponibilités."
Dans mon chose de validation, j'ai déjà une autre fonction.
Voici ma macro actuelle de l'onglet:
____________________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect Password:="Reg" '__________désactive la
protection
If Target.Count > 1 Then Exit Sub
Set isect1 = Application.Intersect(Target, Range("A17:BJ90"))
Set isect2 = Application.Intersect(Target, Range("A96:BJ141"))
Set isect3 = Application.Intersect(Target, Range("A146:BJ166"))
Set isect4 = Application.Intersect(Target, Range("A172:BJ209"))
'____________
If Not isect1 Is Nothing Or Not isect2 Is Nothing Or Not isect3 Is _
Nothing _
Or Not isect4 Is Nothing Then Target.Font.ColorIndex = 3
'_________________
If Target.Column <> 56 Then Exit Sub
If Not IsNumeric(Target.Value) Then Exit Sub
Target.Offset(0, 1).Value = Target.Offset(0, 1).Value + Target.Value
ActiveSheet.Protect Password:="Reg" '______________ l'active
End Sub
____________________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.Unprotect Password:="Reg" '__________désactive la protection If Target.Count > 1 Then Exit Sub Set isect1 = Application.Intersect(Target, Range("A17:BJ90")) Set isect2 = Application.Intersect(Target, Range("A96:BJ141")) Set isect3 = Application.Intersect(Target, Range("A146:BJ166")) Set isect4 = Application.Intersect(Target, Range("A172:BJ209")) '____________
If Not Intersect(Target, Range("BD:BD")) Is Nothing Then If Target > Target(0, -1) Then MsgBox "Le montant est supérieur à vos disponibilités." End If ElseIf Not isect1 Is Nothing Or Not isect2 Is Nothing Or Not isect3 Is _ Nothing _ Or Not isect4 Is Nothing Then Target.Font.ColorIndex = 3 '_________________ If Target.Column <> 56 Then Exit Sub If Not IsNumeric(Target.Value) Then Exit Sub Target.Offset(0, 1).Value = Target.Offset(0, 1).Value + Target.Value ActiveSheet.Protect Password:="Reg" '______________ l'active End Sub
Cordialement. Daniel "Érico" a écrit dans le message de news: u$
Bonjour à tous,
J'ai déjà une macro dans l'onglet dans l'onglet en question pour mettre en caratère rouge, tout changement que l'opérateur fais un faisant un retour de chariot. J'aimerais rajouter une autre macro qui lance un avertissement suivante:
J'ai deux colonnes, BC et BD.
Quand l'utilisateur entre un montant dans BD, il ne doit jamais dépasser le montant de BC. Faire afficher le message: MsgBox "Le montant est supérieur à vos disponibilités."
Dans mon chose de validation, j'ai déjà une autre fonction.
Voici ma macro actuelle de l'onglet: ____________________________________________________________
Private Sub Worksheet_Change(ByVal Target As Range) ActiveSheet.Unprotect Password:="Reg" '__________désactive la protection If Target.Count > 1 Then Exit Sub Set isect1 = Application.Intersect(Target, Range("A17:BJ90")) Set isect2 = Application.Intersect(Target, Range("A96:BJ141")) Set isect3 = Application.Intersect(Target, Range("A146:BJ166")) Set isect4 = Application.Intersect(Target, Range("A172:BJ209")) '____________
If Not isect1 Is Nothing Or Not isect2 Is Nothing Or Not isect3 Is _ Nothing _ Or Not isect4 Is Nothing Then Target.Font.ColorIndex = 3 '_________________ If Target.Column <> 56 Then Exit Sub If Not IsNumeric(Target.Value) Then Exit Sub Target.Offset(0, 1).Value = Target.Offset(0, 1).Value + Target.Value ActiveSheet.Protect Password:="Reg" '______________ l'active End Sub ____________________________________________________________