Sub ChercherBis()
Dim Chaine$, F, Sh, i%, N%, MaRange As Range
Chaine = InputBox("Quelle chaine recherchez vous ?")
If Chaine = "" Then Exit Sub
'Pour toutes les feuilles
For Each F In Worksheets
F.Select
'Pour tous les shapes
For Each Sh In Sheets(F.Name).Shapes
'Si zone de texte alors on récupère les infos
If Sh.Type = msoTextBox Then
If LCase(Sh.TextFrame.Characters.Text) Like "*" & LCase(Chaine) & "*" Then
ActiveSheet.Shapes(Sh.Name).Select
ScrollpCellule Sh.TopLeftCell
DoEvents: Calculate
Rep = MsgBox("Voulez vous le suivant ?", vbQuestion + vbYesNo + vbQuestion, "Recherche de : " & Chaine)
If Rep <> 6 Then Exit Sub
End If
End If
Next Sh
On Error Resume Next
'Combien y a t-il de "Chaine" ?
Set MaRange = Range(Cells(1, 1), Cells(Rows.Count, Columns.Count))
N = Application.CountIf(MaRange, "*" & Chaine & "*")
If N > 0 Then
'On recherche la 1ere
Cells.Find(What:=Chaine, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
'Et on récupère les autres
For i = 1 To N
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Select
DoEvents: Calculate
Rep = MsgBox("Voulez vous le suivant ?", vbQuestion + vbYesNo + vbQuestion, "Recherche de : " & Chaine)
If Rep <> 6 Then Exit Sub
Next i
End If
Next F
End Sub
Sub ScrollpCellule(pCellule As Range)
' Suite à Suivant, on repositionne la textbox Active dans la fenêtre
If pCellule.Column < ActiveWindow.Panes(1).ScrollColumn Then
ActiveWindow.ScrollColumn = pCellule.Column
Else
Application.ScreenUpdating = False
ActiveWindow.Panes(1).LargeScroll 0, 0, 1, 0
If pCellule.Column > ActiveWindow.Panes(1).ScrollColumn Then
ActiveWindow.Panes(1).LargeScroll 0, 0, -1, 0
ActiveWindow.ScrollColumn = pCellule.Column
Else
ActiveWindow.Panes(1).LargeScroll 0, 0, -1, 0
End If
Application.ScreenUpdating = True
End If
If pCellule.Row < ActiveWindow.Panes(1).ScrollRow Then
ActiveWindow.ScrollRow = pCellule.Row
Else
Application.ScreenUpdating = False
ActiveWindow.Panes(1).LargeScroll 1, 0, 0, 0
If pCellule.Row > ActiveWindow.Panes(1).ScrollRow Then
ActiveWindow.Panes(1).LargeScroll -1, 0, 0, 0
ActiveWindow.ScrollRow = pCellule.Row
Else
ActiveWindow.Panes(1).LargeScroll -1, 0, 0, 0
End If
Application.ScreenUpdating = True
End If
End Sub