Supprimer ligne d'un tableau en fonction d'une liste

joums

XLDnaute Occasionnel
Bonjour à tous,

Je bloque sur une macro, en fait je souhaite supprimer toutes les lignes qui ne font pas partie d'un autre tableau
Exemple :
Dans l'onglet A j'ai un tableau 1 avec les noms suivant : JEAN / PIERROT / WILLY
Dans l'onglet B j'ai un tableau 2 avec une liste des X noms dont : JEAN / PIERROT / WILLY

Je veux supprimer toutes les lignes du tableau 2 où les noms du tableau 1 n'apparaissent pas.


Merci pour votre aide
 

instanceM

XLDnaute Nouveau
Re : Supprimer ligne d'un tableau en fonction d'une liste

J'ai eu le mème problème regarde ce code peut ètre t'aidera t'il ( à adapter )

Sub supp ()

ReDim aeff(0)

tablo1 = Sheets("Feuil1").Range("L1:L" & Sheets("Feuil1").Range("L" & Rows.Count).End(xlUp).Row)
tablo2 = Sheets("Feuil2").Range("A1:A" & Sheets("Feuil2").Range("A" & Rows.Count).End(xlUp).Row)

For n = LBound(tablo2, 1) To UBound(tablo2, 1)
For m = LBound(tablo1, 1) To UBound(tablo1, 1)

If tablo2(n, 1) = tablo1(m, 1) Then

exist = True
Exit For

End If

Next

If exist = False Then

aeff(UBound(aeff)) = n

ReDim Preserve aeff(UBound(aeff) + 1)

Else

exist = False

End If

Next

Application.ScreenUpdating = False

For n = UBound(aeff) - 1 To LBound(aeff) Step -1

Sheets("Feuil2").Rows(aeff(n)).Delete

Next

Application.ScreenUpdating = True

End Sub
 

joums

XLDnaute Occasionnel
Re : Supprimer ligne d'un tableau en fonction d'une liste

J'ai eu le mème problème regarde ce code peut ètre t'aidera t'il ( à adapter )

Sub supp ()

ReDim aeff(0)

tablo1 = Sheets("Feuil1").Range("L1:L" & Sheets("Feuil1").Range("L" & Rows.Count).End(xlUp).Row)
tablo2 = Sheets("Feuil2").Range("A1:A" & Sheets("Feuil2").Range("A" & Rows.Count).End(xlUp).Row)

For n = LBound(tablo2, 1) To UBound(tablo2, 1)
For m = LBound(tablo1, 1) To UBound(tablo1, 1)

If tablo2(n, 1) = tablo1(m, 1) Then

exist = True
Exit For

End If

Next

If exist = False Then

aeff(UBound(aeff)) = n

ReDim Preserve aeff(UBound(aeff) + 1)

Else

exist = False

End If

Next

Application.ScreenUpdating = False

For n = UBound(aeff) - 1 To LBound(aeff) Step -1

Sheets("Feuil2").Rows(aeff(n)).Delete

Next

Application.ScreenUpdating = True

End Sub

Je ne comprends pas tout le code,
j'ai tenté de l'adapté mais sans succès
 

Discussions similaires

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
312 389
Messages
2 087 933
Membres
103 678
dernier inscrit
bibitm