Sub SupprimerColonnes()
Dim rep As Byte, derlig&
rep = MsgBox("Cliquez sur Oui pour supprimer uniquement les colonnes sélectionnées." _
& vbLf & "Cliquez sur Non pour supprimer toutes les colonnes.", 51, _
"Dates de fin antérieures à 60 jours")
If rep = 2 Then Exit Sub 'bouton Annuler
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
On Error Resume Next 's'il n'y a aucune colonne à supprimer
[1:1].Insert 'ligne auxiliaire
With Intersect([O1].Resize(, Columns.Count - 14), ActiveSheet.UsedRange.EntireColumn)
derlig = .EntireColumn.Find("*", , xlFormulas, , xlByRows, xlPrevious).Row
If rep = 6 Then .Value = 0
IIf(rep = 6, Intersect(Selection.EntireColumn, .Cells), .Cells) _
.FormulaR1C1 = "=LN(R3C>=TODAY()-60)"
.Value = .Value 'suppression des formules
.Resize(derlig).Sort Rows(1), xlAscending, Orientation:=xlLeftToRight 'tri
Intersect(.SpecialCells(xlCellTypeConstants, 16).EntireColumn, Rows("1:" & derlig)).Delete xlToLeft
.EntireColumn.AutoFit 'ajustement automatique
End With
[1:1].Delete 'suppression de la ligne auxiliaire
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub