Suppression de ligne

Fermé
Magali - 30 nov. 2020 à 15:22
yg_be Messages postés 22719 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 23 avril 2024 - 30 nov. 2020 à 16:57
Bonjour,

Je cherche à créer un code qui pourrait me supprimer toutes les lignes contenant le texte "Amazon" dans la colonne A.

Je ne sais pas si c'est très clair...

Merci pour votre aide :)

Configuration: Windows / Chrome 87.0.4280.66
A voir également:

1 réponse

yg_be Messages postés 22719 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 23 avril 2024 1 476
30 nov. 2020 à 16:57
bonjour,
suggestion:
Sub exterminer_amazon()
Dim rg As Range, sh As Worksheet, ligdeb As Long, ligfin As Long, nlig As Long
Set sh = ActiveSheet
Set rg = Intersect(sh.UsedRange, sh.Columns("a"))
If Not rg Is Nothing Then
    ligdeb = rg.Row
    ligfin = ligdeb + rg.Rows.Count - 1
    For nlig = ligfin To ligdeb Step -1
        If sh.Cells(nlig, 1) = "Amazon" Then
            sh.Rows(nlig).Delete
        End If
    Next nlig
End If
End Sub
0