Private Sub RechercheQuoi(Quoi As Variant)
'Application.EnableEvents = False
'Application.ScreenUpdating = False
Dim Sh As Worksheet, Trouve As Range, SvgAdres$, T$, M$, F$, AdresSource$
F$ = ActiveSheet.Name
Select Case F$
Case "Feuil1": AdresSource$ = "G9"
Case "Feuil2": AdresSource$ = "G9"
Case "Feuil3": AdresSource$ = "G9"
Case "Feuil4": AdresSource$ = "G9"
Case Else: Exit Sub '
End Select
T = "Pas"
'Quoi = Format(Quoi, "0#"" ""##"" ""##"" ""##"" ""##")'< ceci uniquement si tu veux rechercher avec no formaté
'boucle feuilles
For Each Sh In Worksheets
Set Trouve = Sh.Cells.Find(Quoi, LookIn:=xlFormulas, LookAt:=xlPart, MatchCase:=False, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not Trouve Is Nothing Then
Sh.Activate: SvgAdres = Trouve.Address
'n'affiche pas la cellule source
If Trouve.Address(False, False) <> AdresSource$ Then
Trouve.Select
Selection.EntireRow.Hidden = False
M$ = "Trouvé !" & vbLf & "Feuille: " & Sh.Name & vbLf & "Adresse: " & Trouve.Address(False, False) & vbLf & vbLf & "Recherche suivant ?"
If MsgBox(M$, vbYesNo, "Recherche de " & Quoi) = vbNo Then Exit Sub 'MsgBox "Recherche arrêtée !", , "Oups":
T = "Plus "
End If
'
Do 'boucle sur même feuille
Set Trouve = Sh.Cells.FindNext(Trouve)
If Trouve Is Nothing Then Exit Do 'en 1'
If Trouve.Address = SvgAdres Then Exit Do 'si retour à la 1'trouvée exit do feuil.suivante
T = "Plus ": Trouve.Select
Selection.EntireRow.Hidden = False
M$ = "Trouvé !" & vbLf & "Feuille: " & Sh.Name & vbLf & "Adresse: " & Trouve.Address(False, False) & vbLf & vbLf & "Recherche suivant ?"
If MsgBox(M$, vbYesNo, "Recherche de " & Quoi) = vbNo Then Exit Sub 'MsgBox "Recherche arrêtée !", , "Oups":
Loop
End If
Next
If T = "Pas" Then
MsgBox "Recherche infructueuse !", , "Oups"
Unload fm_SaisieRecherche
Else
MsgBox "Recherche terminéee !", , "Très bon boulot ..."
Unload fm_SaisieRecherche
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub