Suppression lignes après recherche sur conditions

Web68

XLDnaute Nouveau
Bonjour à tous,

je cherche une macro pour faire
rechercher et afficher sur critère
et ensuite une macro pour suppression de la ligne si critère ok

merci
 

Pièces jointes

  • test.xls
    15 KB · Affichages: 35
  • test.xls
    15 KB · Affichages: 45
  • test.xls
    15 KB · Affichages: 48

WUTED

XLDnaute Occasionnel
Re : Suppression lignes après recherche sur conditions

Bonjour Web68, le forum,

Voici ton fichier modifié, j'ai rajouté un bouton pour vider les champs.

Bonne journée,
WUTED
 

Pièces jointes

  • test.xls
    45.5 KB · Affichages: 73
  • test.xls
    45.5 KB · Affichages: 69
  • test.xls
    45.5 KB · Affichages: 71

Web68

XLDnaute Nouveau
Re : Suppression lignes après recherche sur conditions

Franchement trop top et chapeau bas :cool:
merci à toi j’attendais une aide et vlà que le boulot est fait !!!

dernière question si je supprime il ne fait que vider les cellules et la ligne reste. Y a t-il une solution ou faut il que je refasse un tri ?

Merci bon week à tous
 

WUTED

XLDnaute Occasionnel
Re : Suppression lignes après recherche sur conditions

Bonjour Web68, le forum,

Supprime la fonction Supprimer() que t'as dans le module (Supprimeception) et remplace la par :
VB:
Sub Supprimer()
    Dim mnom As String, mprenom As String, mdate As String
    
    mdate = ThisWorkbook.Sheets("Feuil2").Range("B12").Value
    mnom = ThisWorkbook.Sheets("Feuil2").Range("C12").Value
    mprenom = ThisWorkbook.Sheets("Feuil2").Range("D12").Value
    
    For i = 1 To ThisWorkbook.Sheets("Feuil1").Range("E65536").End(xlUp).Row
        If mdate = ThisWorkbook.Sheets("Feuil1").Range("E" & i).Value And mnom = ThisWorkbook.Sheets("Feuil1").Range("F" & i).Value And mprenom = ThisWorkbook.Sheets("Feuil1").Range("G" &_      i).Value Then
            ThisWorkbook.Sheets("Feuil1").Range("E" & i).Value = ""
            ThisWorkbook.Sheets("Feuil1").Range("F" & i).Value = ""
            ThisWorkbook.Sheets("Feuil1").Range("G" & i).Value = ""
        For j = i To ThisWorkbook.Sheets("Feuil1").Range("E65536").End(xlUp).Row
            ThisWorkbook.Sheets("Feuil1").Range("E" & j).Value =_ ThisWorkbook.Sheets("Feuil1").Range("E" & j + 1).Value
            ThisWorkbook.Sheets("Feuil1").Range("F" & j).Value =_ ThisWorkbook.Sheets("Feuil1").Range("F" & j + 1).Value
            ThisWorkbook.Sheets("Feuil1").Range("G" & j).Value =_ ThisWorkbook.Sheets("Feuil1").Range("G" & j + 1).Value
        Next
        Exit For
        End If
    Next
End Sub

Bonne soirée,
WUTED

Edit : Désolé pour les 3 lignes de code qui se sont passées à la ligne, j'arrive pas à te les afficher autrement en gardant une indentation correcte...
 
Dernière édition:

Web68

XLDnaute Nouveau
Re : Suppression lignes après recherche sur conditions

Wuted si tu es encore la ... avec mes 3 critères de recherche quand je ramène le résultat sur la première feuille j'aimerai ramener 3 cellules supplémentaires qui sont à la suite de E,F,G qu'on ramène déjà par la macro, les colonnes H,I,J.
tu peux m’aiguiller ?
MERCI
 

WUTED

XLDnaute Occasionnel
Re : Suppression lignes après recherche sur conditions

Re, si j'ai compris ce que tu voulais, tu mets ces nouvelles fonctions à la place des autres, et tu devrais avoir ce que tu veux :
VB:
Sub Recherche()
    Dim mnom As String, mprenom As String, mdate As String
    
    mdate = ThisWorkbook.Sheets("Feuil2").Range("B8").Value
    mnom = ThisWorkbook.Sheets("Feuil2").Range("C8").Value
    mprenom = ThisWorkbook.Sheets("Feuil2").Range("D8").Value
    
    For i = 1 To ThisWorkbook.Sheets("Feuil1").Range("E65536").End(xlUp).Row
        If mdate = ThisWorkbook.Sheets("Feuil1").Range("E" & i).Value And mnom = ThisWorkbook.Sheets("Feuil1").Range("F" & i).Value And mprenom = ThisWorkbook.Sheets("Feuil1").Range("G" & i).Value Then
            ThisWorkbook.Sheets("Feuil2").Range("B12").Value = mdate
            ThisWorkbook.Sheets("Feuil2").Range("C12").Value = mnom
            ThisWorkbook.Sheets("Feuil2").Range("D12").Value = mprenom
            ThisWorkbook.Sheets("Feuil2").Range("E12").Value = ThisWorkbook.Sheets("Feuil1").Range("H" & i).Value
            ThisWorkbook.Sheets("Feuil2").Range("F12").Value = ThisWorkbook.Sheets("Feuil1").Range("I" & i).Value
            ThisWorkbook.Sheets("Feuil2").Range("G12").Value = ThisWorkbook.Sheets("Feuil1").Range("J" & i).Value
            
            Exit For
        End If
    Next
End Sub
Sub Supprimer()
    Dim mnom As String, mprenom As String, mdate As String
    
    mdate = ThisWorkbook.Sheets("Feuil2").Range("B12").Value
    mnom = ThisWorkbook.Sheets("Feuil2").Range("C12").Value
    mprenom = ThisWorkbook.Sheets("Feuil2").Range("D12").Value
    
    For i = 1 To ThisWorkbook.Sheets("Feuil1").Range("E65536").End(xlUp).Row
        If mdate = ThisWorkbook.Sheets("Feuil1").Range("E" & i).Value And mnom = ThisWorkbook.Sheets("Feuil1").Range("F" & i).Value And mprenom = ThisWorkbook.Sheets("Feuil1").Range("G" & i).Value Then
            ThisWorkbook.Sheets("Feuil1").Range("E" & i).Value = ""
            ThisWorkbook.Sheets("Feuil1").Range("F" & i).Value = ""
            ThisWorkbook.Sheets("Feuil1").Range("G" & i).Value = ""
            ThisWorkbook.Sheets("Feuil1").Range("H" & i).Value = ""
            ThisWorkbook.Sheets("Feuil1").Range("I" & i).Value = ""
            ThisWorkbook.Sheets("Feuil1").Range("J" & i).Value = ""
            Exit For
        End If
    Next
End Sub

WUTED
 

Discussions similaires

Réponses
2
Affichages
84

Statistiques des forums

Discussions
312 153
Messages
2 085 800
Membres
102 980
dernier inscrit
brossadan