Application.Match

SandraSSQ

XLDnaute Nouveau
Bonjour,

J'ai créé cette macro pour éliminer des noms dans un tableau que j'ai listé dans la feuille Procédure. Les noms sont listés dans la colonne A à partir de la cellule A30. Je ne comprends pas car la macro élimine des lignes mais pas celle qui correspondes au bon nom dans le tableau Plan sommaire détaillé (2). Est-ce qu'il y a une erreur dans cette macro?

Un gros merci pour votre aide!

Sub macro2()
With Sheets("Procédure")
For Each c In .Range("A30:A" & .Range("A" & Rows.Count).End(xlUp).Row)
ligne = Application.Match(c, Sheets("Plan Sommaire détaillé (2)").Range("B10:B200"), 0)
If Not IsError(ligne) Then Sheets("Plan Sommaire détaillé (2)").Rows(ligne).Delete
Next c
End With



End Sub
 

Dranreb

XLDnaute Barbatruc
Bonsoir.
Le numéro de ligne dans la plage B10:B200 ce n'est pas le numéro de ligne dans la feuille !
Essayez voir comme ça :
VB:
Sub macro2()
Dim RngProc As Range, RngPlan As Range, Cel As Range, L
With Worksheets("Procédure")
   Set RngProc = .[A30].Resize(.Cells(.Rows.Count, "A").End(xlUp).Row - 29)
   End With
Set RngPlan = Worksheets("Plan Sommaire détaillé (2)").[B10:B200]
For Each Cel In RngProc
   L = Application.Match(Cel, RngPlan, 0)
   If Not IsError(L) Then RngPlan(L, 1).EntireRow.Delete
   Next Cel
End Sub
 

SandraSSQ

XLDnaute Nouveau
Bonsoir.
Le numéro de ligne dans la plage B10:B200 ce n'est pas le numéro de ligne dans la feuille !
Essayez voir comme ça :
VB:
Sub macro2()
Dim RngProc As Range, RngPlan As Range, Cel As Range, L
With Worksheets("Procédure")
   Set RngProc = .[A30].Resize(.Cells(.Rows.Count, "A").End(xlUp).Row - 29)
   End With
Set RngPlan = Worksheets("Plan Sommaire détaillé (2)").[B10:B200]
For Each Cel In RngProc
   L = Application.Match(Cel, RngPlan, 0)
   If Not IsError(L) Then RngPlan(L, 1).EntireRow.Delete
   Next Cel
End Sub


Super! Ça fonctionne très bien. Merci pour votre aide!
 

Discussions similaires

Statistiques des forums

Discussions
312 193
Messages
2 086 059
Membres
103 110
dernier inscrit
Privé