Macro supprimer ligne

Bonjour,

Je souhaiterais supprimer les lignes du fichier dont la celulle en colonne A commence par Moyen

La macro ne fonctionne pas (le fichier peut contenir plus de 10 000 lignes)

Sub test
Dim I As Long
Dim Plage As Range
Set Plage = Range("A1:A" & Range("A1").End(xlDown).Row)
For I = Plage.Cells.Count To 1 Step -1
  If UCase(Plage.Cells(I).Value) Like "Moyen*" Then
    Plage.Cells(I).EntireRow.Delete
  End If
Next
End Sub

Merci de votre aide

10ess.xlsm (15.93 Ko)

Bonjour

Essaie ce code :

Sub SupprimerLesLignesMoyen()
    For i = Range("A1").End(xlDown).Row To 1 Step -1
        If UCase(Cells(i, 1).Value) Like "MOYEN*" Then
            Rows(i).EntireRow.Delete
        End If
    Next i
End Sub

Bye !

Le code fonctionne bien par contre j'ai un fichier de 5000 lignes du coup ça prend plus de 30 secondes pour supprimer les lignes.

Il n'y a pas un code plus rapide ?

Bonjour

Bigben2013 a écrit :

contre j'ai un fichier de 5000 lignes du coup ça prend plus de 30 secondes pour supprimer les lignes.Il n'y a pas un code plus rapide ?

Joins ton fichier et on regardera ça.

Bye !

Salut BigBen,

voici un fichier de 100.000 lignes! Démarrage macro : clic en [A1]... vroooom!

'
Dim tTab
Dim iRow As Long, iCol%
'
Application.ScreenUpdating = False
'
If Target.Address = [A1].Address Then
    iRow = UsedRange.Rows.Count
    iCol = UsedRange.Columns.Count
    tTab = Range("A1").Resize(iRow, iCol)
    '
    For x = 1 To UBound(tTab, 1)
        If UCase(tTab(x, 1)) Like "MOYEN*" Then tTab(x, 1) = ""
    Next
    Range("A1").Resize(iRow, iCol) = tTab
    Range("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End If
'
Application.ScreenUpdating = True
'

A+

11ess.xlsm (319.25 Ko)

Voilà mon fichier.

Je commence ma macro à partir de la ligne 5000.

5b.xlsm (242.24 Ko)

curulis57,

tu as mis où ton code dans le fichier ? (je ne le trouve pas )

Salut Bigben,

désolé, j'ai loupé ton message!

Le code se trouve dans le module de la feuille Feuil1, procédure événementielle Worksheet_SelectionChange.

A+

Rechercher des sujets similaires à "macro supprimer ligne"