![]() |
|
Forum
|
|
|
#1 (permalink) |
|
Guest
Messages: n/a
|
j'ai besoin d'un petit coup de main. je tente de créer une sorte de macro "moteur de recherche" déclenchant une recherche sur toutes les feuilles. mais je ne maitrise pas tres bien VBA... si quelqu'un peut m'aider... merci. voici la macro : Private Sub CommandButton2_Click() mot = InputBox("Mot à rechercher ? (mot simple ou suite logique)") If mot = "" Then Exit Sub For feuille = 1 To Sheets.Count Sheets(feuille).Select Set trouvé1 = Cells.Find(What:=mot) If Not trouvé1 Is Nothing Then With trouvé1 .Activate .Select .Font.ColorIndex = 3 End With étiq: If MsgBox("Suivant ?", 4) = vbNo Then Exit Sub Set trouvé2 = Cells.FindNext(After:=ActiveCell) Set trouvé3 = Cells.FindPrevious(After:=ActiveCell) Do While trouvé2 <> trouvé1 With trouvé1 .Select .Font.ColorIndex = 0 End With With trouvé3 .Select .Font.ColorIndex = 0 End With With trouvé2 .Activate .Select .Font.ColorIndex = 3 End With GoTo étiq Loop End If Next feuille MsgBox "Rien trouvé" End Sub |
| ANNONCES | |||
|
|
|
|
#2 (permalink) |
|
Guest
Messages: n/a
|
bonjour
la macro ci-dessous ne te convient pas ???? Sub RechercheMot() mot = InputBox("Mot à rechercher ?") For feuille = 1 To sheets.Count sheets(feuille).Select : Set trouvé1 = Cells.find(What:=mot) If Not trouvé1 Is Nothing Then trouvé1.Activate ' call tamacro étiq: If MsgBox("suivant?", 4) = vbNo Then Exit Sub Set trouvé2 = Cells.findNext(After:=ActiveCell) If trouvé2.Column <> trouvé1.Column Or trouvé2.Row <> trouvé1.Row Then trouvé2.Activate 'call tamacro GoTo étiq End If End If Next feuille End Sub |
|
|
#3 (permalink) |
|
Guest
Messages: n/a
|
en fait je suis partie de cette macro. mais elle ne fonctionne pas correctement sur mon workbook. elle trouve le mot recherché sur la feuille 1 mais pas sur les autres (pourtant elle les visionne ?!). j'ai toujours ce problème avec "ma" version.
je viens de créer un autre workbook pour tester la macro... elle fonctionne en effet très bien. le problème vient donc de mon workbook. j'utilise beaucoup la fonction "regroupement de lignes", est ce que le problème peut venir de là ?? malheureusement je ne peux pas mettre mon fichier en piece jointe, trop lourd (6MO). |
| ANNONCES | |
| Liens sociaux |
| Outils de la discussion | |
|
|