Recherche sur plusieurs feuilles

C

cutbill1234

Guest
Bonjour,

je voudrais savoir comment je peux réaliser une recherche sur plusieurs feuille (d'un même classeur) en même temps.

Merci.
 
C

cutbill1234

Guest
bonjour,
j'ai testé seulement j'aurais besoin d'un mix des deux recherches. En effet la recherche 1 permet de retrouver une cellule même si on ne rentre pas le mot exact (exemple pour le cas : en tapant "five", "five years" est retrouvé. Ce n'est pas le cas pour la recherche 2. Cela dit l'avantage de la recherche 2, c'est qu'elle nous met sur la cellule recherchée. J'aurais donc besoin de la version 2 mais capable de trouver comme la 1.

Merci beaucoup

Cutbill
 
M

michel

Guest
rebonjour Cutbill

j'espere que cette adaptation repondra à ta demande


Sub CommandButton2_Click()
'adaptation procedure de Didou
'http://www.excel-downloads.com/html/French/forum/messages/1_59385_59385.htm
Dim strSearchString As String
Dim ws As Worksheet
Dim foundCell As Range
Dim loopAddr As String, returnValue As String


strSearchString = InputBox(Prompt:="Saisir la valeur à chercher.", Title:="Recherche")

If strSearchString = "" Then Exit Sub

For Each ws In Worksheets
With ws
.Activate
Set foundCell = .Cells.Find(What:=strSearchString, LookIn:=xlValues, LookAt:=xlPart)

If Not foundCell Is Nothing Then
loopAddr = foundCell.Address
Do
foundCell.Activate
returnValue = MsgBox("valeur trouvée dans " & ws.Name & " " & foundCell.Address & vbLf & _
"Voulez vous continuer la recherche ? ", vbYesNo, "Message")
If returnValue = vbNo Then Exit For
Set foundCell = .Cells.FindNext(After:=foundCell)
Loop While Not foundCell Is Nothing And foundCell.Address <> loopAddr
End If
End With

Next ws

End Sub


bon week end
MichelXld
 
C

cutbill1234

Guest
Bonjour,

merci pour le programme. Je voudrais savoir quel est la fonction qui permet de rester sur la cellule une fois le résultat trouvé car malheureusement ta macro me fait revenir sur la page de garde.

Merci

Cutbill
 
M

michel

Guest
bonjour Cutbill

chez moi la procédure s'arrete sur la derniere cellule contenant la valeur recherchée , ou dans la derniere feuille du classeur si aucune donnée n'est trouvée
utilises tu la macro tel quel ? ( verifies que tu n'as pas la ligne "Sheets(1).Select" , en fin de procedure )
lances tu la macro depuis la page de garde ?
la page de garde contient elle des données à rechercher ?


bon dimanche
MichelXld
 
C

cutbill1234

Guest
Bonjour michel,

en fait j'ai fait un mix des deux macros, le problème c'est que je n'arrive pas rester (comme le fait ta macro) sur la valeur trouvée. Lorsque je retire "Sheets(1).Select", j'ai soit une erreur, soit le problème est toujours le même. Voici le prog, qu'est-ce qui cloche ??

Sub CommandButton2_Click()
Dim countTot As Long
Dim counter As Long
Dim strSearchString As String
Dim ws As Object
Dim foundCell As Variant
Dim loopAddr As Variant
Dim returnValue As String


strSearchString = InputBox(Prompt:="Saisir la valeur à chercher.", Title:="Recherche")

If strSearchString = "" Then Exit Sub

For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, "=" & strSearchString)
Next ws

If countTot = 0 Then
MsgBox (strSearchString & " n'est pas une valeur enregistrée.")
Else
counter = 0
For Each ws In Worksheets
With ws
.Activate
Set foundCell = .Cells.Find(What:=strSearchString, LookIn:=xlValues, LookAt:=xlPart)

If Not foundCell Is Nothing Then
loopAddr = foundCell.Address
Do
counter = counter + 1
foundCell.Activate
returnValue = MsgBox(" La valeur " & strSearchString & " est enregistrée " & countTot & " fois " & vbLf & _
" Voulez vous continuer la recherche ? ", vbYesNo, "Message")
If returnValue = vbNo Then Exit For
Set foundCell = .Cells.FindNext(After:=foundCell)
Loop While Not foundCell Is Nothing And _
foundCell.Address <> loopAddr
End If
End With

Next ws

End If

Sheets(1).Select

End Sub
 

Discussions similaires

Réponses
16
Affichages
757

Statistiques des forums

Discussions
312 975
Messages
2 094 095
Membres
105 937
dernier inscrit
thibodu388