1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Err_Worksheet_Change
Dim Cel As Range
If Intersect(Range("A:B"), Target) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each Cel In Intersect(Range("A:B"), Target)
If Cel.Columns = 1 Then
Cel.Offset(0, 1) = Cel
Else
Cel.Offset(0, -1) = Cel
End If
Next Cel
Sort_Worksheet_Change:
Application.ScreenUpdating = True
Application.EnableEvents = True
Exit Sub
Err_Worksheet_Change:
MsgBox Err.Description, vbOKOnly + vbCritical, "Erreur n°" & Err.Number
Resume Sort_Worksheet_Change
End Sub |
Partager