XL 2013 Développement d'un programme "VBA" pour suppression des lignes avec une seul condition

Anr1

XLDnaute Occasionnel
Supporter XLD
Bonjour Forum,

Ci-joint un fichier avec un programme VBA pour suppression des lignes de la Feuil1 si la valeur de la colonne" D" Feuil2 n'existe pas sur la colonne "L" Feuil1

Le programme marche très bien à l'aide de Mr @pierrejean

par contre ma base de donner contient 85000 ligne et le programme prendre bcp de temps et il supprime pas tous les lignes à la fois je clic 10 fois pour le bouton et a chaque fois le programme supprime des ligne jusque un moment ou il supprime tous les lignes.

Est ce que vous pouvez développer le programme pour qu’il soit plus rapide et efficace :)

VB:
Sub supp_lignes()

Application.ScreenUpdating = False
For n = 2 To Range("L" & Rows.Count).End(xlUp).Row
Set c = Sheets("Feuil2").Columns("D").Find(Range("L" & n), LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then Rows(n).Delete
Next
Application.ScreenUpdating = True
End Sub


Merci bien
 

Pièces jointes

  • Test (65) (1).xlsm
    24.5 KB · Affichages: 7

dg62

XLDnaute Barbatruc
re
VB:
Sub supp_lignes()

Application.ScreenUpdating = False
For n = Range("L" & Rows.Count).End(xlUp).Row to 2 step -1 ' on commence par le bas ainsi toutes les lignes sont passées en revue au premier passage de la boucle
Set c = Sheets("Feuil2").Columns("D").Find(Range("L" & n), LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then Rows(n).Delete
Next
Application.ScreenUpdating = True
End Sub
 

dg62

XLDnaute Barbatruc
essayez cette procédure

Sub supp_lignes()

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
For n = Range("L" & Rows.Count).End(xlUp).Row to 2 step -1 ' on commence par le bas ainsi toutes les lignes sont passées en revue au premier passage de la boucle
Set c = Sheets("Feuil2").Columns("D").Find(Range("L" & n), LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then Rows(n).Delete
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub
 

Anr1

XLDnaute Occasionnel
Supporter XLD
@dg62
le programme de @pierrejean est bcp plus rapide voilà le programme :

VB:
Sub supp_lignes()
Dim zone As Range
Application.ScreenUpdating = False
For n = Range("L" & Rows.Count).End(xlUp).Row To 2 Step -1
 Set c = Sheets("Feuil2").Columns("D").Find(Range("L" & n), LookIn:=xlValues, lookat:=xlWhole)
 If c Is Nothing Then
    If zone Is Nothing Then
      Set zone = Rows(n)
    Else
      Set zone = Application.Union(zone, Rows(n))
    End If
 End If
Next
zone.Delete
Application.ScreenUpdating = True
End Sub


Merci :)
 

Discussions similaires

Statistiques des forums

Discussions
312 082
Messages
2 085 170
Membres
102 805
dernier inscrit
emes