utilisation de Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Le
JP

Bonjour,
Dans ce type de code, comment sortir de la boucle infernale. En fin de bouc=
le, le Range(Ad).select déclenche à nouveau la macro.
Merci JP
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim l As Integer
Dim Ad As Variant
'-
If Not Intersect(Target, Range("D25:I226")) Is Nothing Then
Ad = ActiveCell.Address
l = ActiveCell.Row
'Application.ScreenUpdating = False
Range("C25:C226").Select
Selection.Font.ColorIndex = 2
Cells(l, 3).Select
Selection.Font.Color = 0
End If
Range(Ad).Select
End Sub
Dans ce type de code, comment sortir de la boucle infernale. En fin de bouc=
le, le Range(Ad).select déclenche à nouveau la macro.
Merci JP
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim l As Integer
Dim Ad As Variant
'-
If Not Intersect(Target, Range("D25:I226")) Is Nothing Then
Ad = ActiveCell.Address
l = ActiveCell.Row
'Application.ScreenUpdating = False
Range("C25:C226").Select
Selection.Font.ColorIndex = 2
Cells(l, 3).Select
Selection.Font.Color = 0
End If
Range(Ad).Select
End Sub
Tu peux mettre ça :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim l As Integer
Dim Ad As Variant
'-------
Application.EnableEvents = False
If Not Intersect(Target, Range("D25:I226")) Is Nothing Then
Ad = ActiveCell.Address
l = ActiveCell.Row
'Application.ScreenUpdating = False
Range("C25:C226").Select
Selection.Font.ColorIndex = 2
Cells(l, 3).Select
Selection.Font.Color = 0
End If
Range(Ad).Select
Application.EnableEvents = True
End Sub
Toutefois, si la condition :
If Not Intersect(Target, Range("D25:I226")) Is Nothing Then
n'est pas remplie, Ad n'est pas défini, ce qui doit provoquer une
erreur. Peut-être comme ça :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim l As Integer
Dim Ad As Variant
'-------
If Not Intersect(Target, Range("D25:I226")) Is Nothing Then
Ad = ActiveCell.Address
l = ActiveCell.Row
'Application.ScreenUpdating = False
Range("C25:C226").Font.ColorIndex = 2
Cells(l, 3).Font.Color = 0
End If
End Sub
Daniel
JP
J'ai rien fait......Moi!
;o))
--
Salutations
JJ
"JP"
Merci Jacky, ça fonctionne.
JP
JP
Désolé Daniel :-o)
JP