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
Dim Tab_V()
Private Sub Worksheet_Activate()
Dim X As Long
ReDim Tab_V(1 To 2, 1 To Selection.Cells.Count)
For X = 1 To Selection.Cells.Count
Tab_V(1, X) = Selection.Cells(X)
Tab_V(2, X) = Selection.Cells(X).Address(0, 0)
Next X
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Err_Trait
Dim Cel As Range
Dim X As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each Cel In Target
For X = 1 To UBound(Tab_V, 2)
If Cel.Address(0, 0) = Tab_V(2, X) And Cel <> Tab_V(1, X) Then
'traitement si cellule a effectivement changé
End If
Next X
Next Cel
Err_Trait:
If Err.Number <> 0 Then MsgBox Err.Description, , "Erreur n°" & Err.Number
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim X As Long
ReDim Tab_V(1 To 2, 1 To Target.Cells.Count)
For X = 1 To Target.Cells.Count
Tab_V(1, X) = Target.Cells(X)
Tab_V(2, X) = Target.Cells(X).Address(0, 0)
Next X
End Sub |
Partager