Macro supprimer ligne ne fonctionne pas

Laurentl

XLDnaute Nouveau
Bonjour à tous!

Je ne comprends pas mon erreur dans cette macro pour supprimer la ligne dont la cellule en colonne B est vide:

Sub Macro()
For i = 1 To Range("A6000").End(xlUp).Row
If Cells(i, 3).Value = "" Then
Rows(i).EntireRow.Delete
End If
Next i
End Sub

Vous le verrez dans mon fichier joint.

Merci!
 

Pièces jointes

  • TEST (2).xlsm
    132.4 KB · Affichages: 40
  • TEST (2).xlsm
    132.4 KB · Affichages: 45
  • TEST (2).xlsm
    132.4 KB · Affichages: 39
Dernière édition:

Pierrot93

XLDnaute Barbatruc
Re : Macro supprimer ligne ne fonctionne pas

Bonjour,

pas ouvert ton fichier, mais lorsque tu supprimes des lignes il faut commencer par la fin et remonter, essaye peut être en modifiant comme suit :
Code:
Option Explicit
Sub Macro()
Dim i As Long
For i = Range("A6000").End(xlUp).Row To 1 Step -1
    If Cells(i, 3).Value = "" Then Rows(i).Delete
Next i
End Sub
bon après midi
@+

Edition : bonjour Roland:)
 

Roland_M

XLDnaute Barbatruc
Re : Macro supprimer ligne ne fonctionne pas

re

voir ceci fonctionne !

Code:
Sub Macro()
Application.ScreenUpdating = False
For i = Columns(1).Rows(ActiveSheet.Rows.Count).End(xlUp).Row To 1 Step -1
If Cells(i, 3).Value = "" Then Rows(i).EntireRow.Delete
Next i
Application.ScreenUpdating = True
End Sub
 

Discussions similaires

Réponses
2
Affichages
109

Statistiques des forums

Discussions
312 332
Messages
2 087 361
Membres
103 530
dernier inscrit
Chess01