Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cc%, T As Range, col%, P As Range, I As Range
Static OK As Boolean 'contrôle de sécurité
With [A1].CurrentRegion 'adapter éventuellement
cc = .Columns.Count
Set T = .EntireRow
End With
If Target.Count > 1 Or Target.Row > 1 Or Target.Column < 3 Then End 'RAZ
If OK And Application.CutCopyMode = 2 And Target.Column < cc + 2 Then
Target.Insert xlToRight
If T.Rows.Count > 1 Then
Set T = T.Offset(1).Resize(T.Rows.Count - 1) 'en-têtes non comprises
For col = 4 To cc
If col Mod 2 Then
Set I = Union(IIf(I Is Nothing, T.Columns(col), I), T.Columns(col))
Else
Set P = Union(IIf(P Is Nothing, T.Columns(col), P), T.Columns(col))
End If
Next
If Not I Is Nothing Then I.Interior.ColorIndex = xlNone
If Not P Is Nothing Then P.Interior.Color = 11851260 'couleur modifiable
Set T = Union(T.Rows(0), T)
End If
End If
If Target.Column > 3 And Target.Column <= cc Then
OK = True
Intersect(T, ActiveCell.EntireColumn).Cut
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cc%, T As Range, col%, P As Range, I As Range
Static OK As Boolean 'contrôle de sécurité
With [A1].CurrentRegion 'adapter éventuellement
cc = .Columns.Count
Set T = .EntireRow
End With
If Target.Count > 1 Or Target.Row > 1 Or Target.Column < 4 Then End 'RAZ
If OK And Application.CutCopyMode = 2 And Target.Column < cc + 2 Then
Target.Insert xlToRight
If T.Rows.Count > 1 Then
Set T = T.Offset(1).Resize(T.Rows.Count - 1) 'en-têtes non comprises
For col = 4 To cc
If col Mod 2 Then
Set I = Union(IIf(I Is Nothing, T.Columns(col), I), T.Columns(col))
Else
Set P = Union(IIf(P Is Nothing, T.Columns(col), P), T.Columns(col))
End If
Next
If Not I Is Nothing Then I.Interior.ColorIndex = xlNone
If Not P Is Nothing Then P.Interior.Color = 11851260 'couleur modifiable
Set T = Union(T.Rows(0), T): Set Target = Target(1, 0)
Application.EnableEvents = 0: Target.Select: Application.EnableEvents = -1
End If
End If
If Target.Column <= cc Then
OK = True
T.Columns(Target.Column).Cut
End If
End Sub