Suppression ligne d'un tableau selon critère

Salut le Forum,

pourriez-vous m'aider svp pour avoir une macro qui me permet de supprimer des lignes selon un critère

mon besoin si dans les colonnes "D" existe le critère (SUP) alors après l'exécution de macro toutes la ligne sera supprimé

je vous remercie bcp.

Mon fichier exemple ci-joint

8classeur1.xlsx (10.64 Ko)

Bonjour,

Sub SuppressionLignes()

Dim I As Long, DerniereLigne As Long

    With Sheets("Feuil1")
              DerniereLigne = .Cells(.Rows.Count, "D").End(xlUp).Row
              For I = DerniereLigne To 2 Step -1
                     If UCase(.Cells(I, "D")) = "SUP" Then .Cells(I, "D").EntireRow.Delete
              Next I
    End With

End Sub

Bonjour,
Une autre proposition VBA.
Cdlt.

17classeur1.xlsm (19.15 Ko)
Public Sub DeleteRows()
Dim lastRow As Long, lRow As Long, rng As Range

    With ActiveSheet
        lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
        For lRow = lastRow To 2 Step -1
            If UCase(.Cells(lRow, 4).Value) = "SUP" Then
                If rng Is Nothing Then
                    Set rng = .Cells(lRow, 1).Resize(, 6)
                Else
                    Set rng = Union(rng, .Cells(lRow, 1).Resize(, 6))
                End If
            End If
        Next lRow
        If Not rng Is Nothing Then rng.Delete
    End With

End Sub

bonsoir le fil

la même chose en VBA but avec un autofilter

Sub Avec_Filtre()
     With ActiveSheet.Range("A1").CurrentRegion
          .AutoFilter
          .AutoFilter 4, "sup"
          If .Columns(1).SpecialCells(xlVisible).Count > 1 Then
               Application.DisplayAlerts = False
               .Offset(1).Resize(.Rows.Count - 1, 4).SpecialCells(xlVisible).Delete
               Application.DisplayAlerts = True
          End If
          .AutoFilter
     End With
End Sub

Merci à tous pour votre aide

@Jean-Eric votre proposition me convient parfaitement

Rechercher des sujets similaires à "suppression ligne tableau critere"