Bonjour,
je viens vers vous pour profiter de vos connaissances.
En effet, je viens de construire un code qui permet de supprimer des lignes d'un fichier qui ne m'intéresse pas.
Deux pages dans mon classeur :
- DATA : environ 170 000 lignes
- LISTE PF : Listing de mes produits qui m'intéresse environ 176
Aujourd'hui ma macro fonctionne mais elle prend environ 30mn pour traiter l'onglet Data.
Avez vous des idées pour optimiser le code?
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 Sub pic() Dim nbre_ligne_data, nbre_ligne_pf, cpt_ligne_data, cpt_ligne_pf As Integer Dim ref_data, ref_pf, supp As String nbre_ligne_data = Workbooks("PICPDP.xlsm").Sheets("DATA").Cells(Rows.Count, 1).End(xlUp).Row nbre_ligne_pf = Workbooks("PICPDP.xlsm").Sheets("LISTE PF").Cells(Rows.Count, 1).End(xlUp).Row For cpt_ligne_data = 2 To nbre_ligne_data supp = "OUI" For cpt_ligne_pf = 2 To nbre_ligne_pf ref_data = Workbooks("PICPDP.xlsm").Sheets("DATA").Cells(cpt_ligne_data, 5).Value ref_pf = Workbooks("PICPDP.xlsm").Sheets("LISTE PF").Cells(cpt_ligne_pf, 1).Value If ref_data = ref_pf Then supp = "NON" Exit For End If Next If supp = "OUI" Then Rows(cpt_ligne_data).Delete cpt_ligne_data = cpt_ligne_data - 1 supp = "OUI" End If Next End Sub
Vincent
Partager