boite de dialogue

manulemalin13000

XLDnaute Occasionnel
Bonjour,

J'ai la macro suivante, tres courte qui efface completement une ligne qui contient tel ou tel mot.
Chaque fois que je veux changer de mot je dois modifier la macro.
Serait il possible que quand je lance ma macro une boite de dialogue s ouvre, je rentre le mot et en faisant ok ca s'execute ?

merci pour votre aide


Ici le mot etait SHUTDOWN

Sub test()
Dim cellRecherche As Range
Set cellRecherche = ActiveSheet.Cells.Find("SHUTDOWN", , , xlPart)
While Not cellRecherche Is Nothing
cellRecherche.EntireRow.Delete
Set cellRecherche = ActiveSheet.Cells.Find("SHUTDOWN", , , xlPart)
Wend
End Sub
 

CBernardT

XLDnaute Barbatruc
Re : boite de dialogue

Bonjour manulemalin13000,

Vite fait sans essai :

Sub test()
Dim cellRecherche As Range, LeMot As String
LeMot = InputBox("Saisissez le mot à chercher, merci ", "RECHERCHE D'UN MOT", vbOKCancel)
If LeMot = "" Then Exit Sub
Set cellRecherche = ActiveSheet.Cells.Find(LeMot, , , xlPart)
While Not cellRecherche Is Nothing
cellRecherche.EntireRow.Delete
Set cellRecherche = ActiveSheet.Cells.Find(LeMot, , , xlPart)
Wend
End Sub
 

Papou-net

XLDnaute Barbatruc
Re : boite de dialogue

Bonjour manulemalin,

Modifie ta macro comme ceci :

Code:
Sub test()
Dim cellRecherche As Range, Mot As String
Mot = InputBox("Mot à rechercher", "Effacement ligne")
Set cellRecherche = ActiveSheet.Cells.Find(Mot, , , xlPart)
While Not cellRecherche Is Nothing
cellRecherche.EntireRow.Delete
Set cellRecherche = ActiveSheet.Cells.Find(Mot, , , xlPart)
Wend
End Sub

Bonne journée.

Cordialement.

Edit : Bonjour Bernard,
Ta macro, identique à la mienne, doit fonctionner puisque j'ai testé ma solution (d'où mon leger retard sur toi).

Cordialement.
 
Dernière édition:

Pierrot93

XLDnaute Barbatruc
Re : boite de dialogue

Bonjour à tous,

une autre approche :
Code:
Option Explicit
Sub test()
Dim t As String, x As Range
t = InputBox("mot recherché ?")
If t = "" Then Exit Sub
With ActiveSheet.Cells
    Set x = .Find(t, , xlValues, xlPart, , , False)
    If Not x Is Nothing Then
        Do
            Rows(x.Row).Delete
            Set x = .FindNext
        Loop While Not x Is Nothing
    End If
End With
End Sub

bonne journée
@+
 

Discussions similaires

Statistiques des forums

Discussions
312 763
Messages
2 091 826
Membres
105 076
dernier inscrit
simeand