Sub Efface()
Dim i As Integer
For i = 2 To Range("B" & Rows.Count).End(xlUp).Row
If Cells(i, 3) = "cloturé" And CDate(Cells(i, 9)) < CDate(2016) Then
Cells(i, 3).EntireRow.Delete
End If
Next i
End Sub
Sub a()
Dim pf As Range
With [B1].CurrentRegion
.Item(2, 10).FormulaR1C1 = "=(RC[-8]=""cloturé"")+(YEAR((""1/1/""&RC[-2])*1)<2016)=2"
.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("K1:K2"), Unique:=False
End With
Set pf = [_FilterDataBase]
Application.DisplayAlerts = False
If WorksheetFunction.Subtotal(3, pf.Offset(1).Resize(pf.Rows.Count - 1, 1)) > 0 Then
pf.Offset(1).Resize(pf.Rows.Count - 1).EntireRow.Delete
End If
ActiveSheet.ShowAllData: Range("K1:OK2") = ""
End Sub
Sans boucle (n'est-ce pas Calvus )
5 – La possibilité de joindre des fichiers est donnée sur ce forum. Ne pas hésiter à utiliser cette fonction, tout en veillant que les données soient bidons et donc qu’aucune donnée confidentielle, nominative ne soit dans le fichier.
Sub test_OK()
Dim pf As Range
With [A1].CurrentRegion
.Item(2, 28).FormulaR1C1 = "=(RC4=""clôturé "")+(YEAR((""1/1/""&RC26)*1)<2016)=2"
.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("AB1:AB2"), Unique:=False
End With
Set pf = [_FilterDataBase]
Application.DisplayAlerts = False
If WorksheetFunction.Subtotal(3, pf.Offset(1).Resize(pf.Rows.Count - 1, 1)) > 0 Then
pf.Offset(1).Resize(pf.Rows.Count - 1).EntireRow.Delete
End If
ActiveSheet.ShowAllData: Range("AB1:AB2") = ""
End Sub