Suppression lignes si colonnes A ="X"

bonjour,

J'ai besoin d'une explication. J'ai créé un module, il efface bien les lignes mais il faut relancer plusieurs fois pour effacer tout. Pourquoi?

Voici mon code

Sub SuppressionLigne()
Sheets("Devis-Fact").Activate

Dim prelig 'dernière ligne
Dim derblig

prelig = Sheets("Devis-Fact").Range("A1").End(xlDown).Row

If prelig <> 0 Then
nblig = Application.WorksheetFunction.CountA("Devis-Fact", Range("$A:$A"))
fin = prelig + nblig

'suppression des cellules qui contiennent X dans la colonne A
For i = prelig To fin
'recherche cellule avec X
If Cells(i, 1) = "X" Then
Rows(i).EntireRow.Delete
End If
Next i
End If
End Sub

Merci de votre aide

Bonjour,

De ce que je comprends !...

Cdlt.

Public Sub SuppressionLigne()
Dim lastRow As Long, lRow As Long

    Application.ScreenUpdating = False

    With Worksheets("Devis-Fact")
        lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
        For lRow = lastRow To 1 Step -1
            If .Cells(lRow, 1) = "X" Then .Rows(lRow).EntireRow.Delete
        Next lRow
    End With

End Sub

Bonjour,

Oups ! Désolé...

A+

Re,

Bonjour Galopin01

Merci Jean-Eric

Bien plus simple et efficace.

Merci encore

Rechercher des sujets similaires à "suppression lignes colonnes"