XL 2019 Suppression de lignes

HamoudaBA

XLDnaute Occasionnel
Bonjour
Afin de déterminer qui du personnel n'a pas envoyer son rapport de formation, je souhaite supprimer toutes les lignes de la feuilles "Base" contenant le Matricule saisie en feuille "Saisie" en colonne A.
Je vous remercie et navré si j'ai mal interprété ma requête.
 

Pièces jointes

  • Test.xlsx
    492.2 KB · Affichages: 13

Lolote83

XLDnaute Barbatruc
Salut,
Peut être avec ce code
VB:
Sub SupLig()
    With Sheets("saisie")
        For Each xCell In .Range("A1:A21")
            On Error GoTo Suite
            xEquiv = Application.Match(xCell.Value, Sheets("base").Range("A:A"), 0)
            With Sheets("base")
                .Rows(xEquiv & ":" & xEquiv).Delete Shift:=xlUp
            End With
Suite:
        Next xCell
    End With
End Sub
En espérant avoir bien compris la consigne
@+ Lolote83
 

Staple1600

XLDnaute Barbatruc
Bonsoir le fil,


Lolote83
[Juste pour infos]
Pourquoi pas simplement? :)
VB:
Sub SupLig()
    With Sheets("saisie")
        For Each xCell In .Range("A1:A21")
            On Error GoTo Suite
            xEquiv = Application.Match(xCell.Value, Sheets("base").Range("A:A"), 0)
            Sheets("base").Rows(xEquiv).Delete Shift:=xlUp
Suite:
        Next xCell
    End With
End Sub
[/Juste pour infos]
 

mapomme

XLDnaute Barbatruc
Supporter XLD
Bonsoir à tous,

La base est mise à jour quand on active la feuille "Base".
VB:
Private Sub Worksheet_Activate()
Dim t, dico As New Dictionary, elem, i&, j&, n&
  t = Feuil2.Range("a1").CurrentRegion.Value
  If IsEmpty(t) Then MsgBox 0 & " ligne supprimée", vbInformation: Exit Sub
  If Not IsArray(t) Then ReDim t(1 To 1, 1 To 1): t(1, 1) = Feuil2.Range("a1").Value
  If UBound(t) > 0 Then For Each elem In t: dico(CStr(elem)) = "": Next
  t = Range("a1").CurrentRegion.Value: n = 1
  For i = 2 To UBound(t)
    If Not dico.Exists(CStr(t(i, 1))) Then
      n = n + 1
      For j = 1 To UBound(t, 2): t(n, j) = t(i, j): Next
    End If
  Next i
  Application.ScreenUpdating = False
  Range("a1").CurrentRegion.Clear
  Range("a1").Resize(n, UBound(t, 2)) = t
  MsgBox (UBound(t) - n) & " lignes supprimée(s)", vbInformation
End Sub
 

Pièces jointes

  • HamoudaBA- suppr lignes- v1a.xlsm
    560.3 KB · Affichages: 8
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
311 733
Messages
2 082 019
Membres
101 872
dernier inscrit
Colin T