Suppression critère ligne/colonne

Bonsoir à tous,

je cherche à supprimer dans la colonne 1, les lignes correspondant à un certain critère.

Dans la petite macro suivante le critère est "Terminé".

Mon problème est que ce critère n'est pas forcemment sur la colonne 1.

Je souhaite rechercher la colonne "Avancée Fabrication" (voir fichier) qui ne trouvera pas forcemment sur la colonne E.

Sub suppression()

Dim L As Integer

Dim LAT As Long

' nbre de ligne à traiter'

LAT = Range("A" & Rows.Count).End(xlUp).Row + 1

For L = 1 To LAT

If Cells(L, 1) = "Terminé." Then

Rows(L).delete

L = L- 1

End If

Next L

End Sub

Merci de votre aide.

NB: toute modif de ma macro suppressio est la bien venue. Je ne suis pas sur qu'elle soit optimum.

24test.xls (18.50 Ko)

Bonsoir,

Par exemple, comme ceci :

Sub suppression()
Dim L As Integer
Dim LAT As Long, Col As Long
Col = Rows(1).Find("Avancée Fabrication").Column
LAT = Range("A" & Rows.Count).End(xlUp).Row + 1
For L = LAT To 2 Step -1
    If Cells(L, Col) = "Terminé" Then
        Rows(L).Delete
    End If
Next L
End Sub

Bonne soirée

Bonsoir, salut cousinhub,

si beaucoup de lignes, on peut éviter la boucle avec un filtre

Sub suppression()
Dim LAT As Long, Col%
    Application.ScreenUpdating = False
    Col = Rows(1).Find("Avancée Fabrication").Column
    LAT = Range("A" & Rows.Count).End(xlUp).Row + 1

    '--- filtre données = "terminé" en Col ---
    Range("o2") = "=" & Cells(2, Col).Address(RowAbsolute:=False) & "=""Terminé""" 'critère"
    Range("a1:e" & LAT).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
    Range("o1:o2"), Unique:=False
    '--
    On Error Resume Next
    Range("a2:a" & LAT).SpecialCells(xlCellTypeVisible).EntireRow.Delete
    ActiveSheet.ShowAllData
End Sub

Amicalement

Claude

Rechercher des sujets similaires à "suppression critere ligne colonne"