OVH Cloud OVH Cloud

Recherche multi-feille

3 réponses
Avatar
Dom Férampière©®
Bonjour,

Comment faire pour rechercher dans toutes les pages d'un classseur (qui
en contient une douzaine) une case contenant la valeur recherché (texte
ou nombre) ?

Merci.

Je sèche ....

--
Dom Férampière ©®

3 réponses

Avatar
ChrisV
Bonjour Dom Férampière©®,

Sub zaza()
Dim ws As Worksheet
Dim c As Range
reC = InputBox(Chr(10) & "Rechercher :" & Chr(10) & _
"(minuscules ou majuscules...)", "Lancer une recherche...")
If reC = "" Then Exit Sub
For Each ws In Worksheets
With ws.Cells
Set c = .Find(reC)
If Not c Is Nothing Then
adDt = c.Address
With Application
.GoTo Reference:=ws.Range(adDt), Scroll:=True
.ScreenUpdating = True
End With
nreC = MsgBox("Désirez-vous poursuivre la recherche" & Chr(10) _
& "sur les autres onglets ?" & Chr(10), 36, _
"Recherche accomplie...")
If nreC = vbNo Then Exit Sub
Set c = .FindNext(c)
Do
Set c = .FindNext(c)
Loop While c.Address <> adDt
End If
End With
Next ws
rnreC = MsgBox("Aucune autre donnée correspondante à : " & _
UCase(reC), vbInformation, "Lancer une recherche...")
End Sub


ChrisV


"Dom Férampière©®" a écrit dans le message de news:

Bonjour,

Comment faire pour rechercher dans toutes les pages d'un classseur (qui
en contient une douzaine) une case contenant la valeur recherché (texte
ou nombre) ?

Merci.

Je sèche ....

--
Dom Férampière ©®


Avatar
jb
Bonjour,

Je ne sais pas si tu veux la première occurence de chaque onglet ou
toutes les occurences de chaque onglet?

Sub cherche_premiere_occur_chque_onglet()
Dim mot As String, s As Worksheet, c As Range
mot = InputBox("Mot cherché?")
If mot = "" Then Exit Sub
For Each s In ActiveWorkbook.Sheets ' tous les onglets
s.Select
Set c = Cells.Find(mot)
If Not c Is Nothing Then
c.Interior.ColorIndex = 36
End If
Next s
Sheets(1).Select
End Sub

Le pgm ci dessous colorie TOUTES les occurences de chaque onglet:

Sub cherche_tous_onglets()
Dim mot As String, s As Worksheet, c As Range
mot = InputBox("Mot cherché?")
If mot = "" Then Exit Sub
For Each s In ActiveWorkbook.Sheets
s.Select
Set c = Cells.Find(mot)
If Not c Is Nothing Then
premier = c.Address
Do
c.Interior.ColorIndex = 4
Set c = Cells.FindNext(c)
Loop Until c Is Nothing Or c.Address = premier
End If
Next s
Sheets(1).Select
End Sub

Cordialement JB
Avatar
michdenis
Bonjour JB,

Comme dans un de tes messages, tu as fourni beaucoup d'information sur Access et ses requêtes, je trouve que tu devrais faire de
même en ce qui concerne la méthode "Find" dans Excel ! L'usage qui en est fait dans ta procédure pourrait bien t'apporter un lot de
surprise !


Salutations!



"jb" a écrit dans le message de news:
Bonjour,

Je ne sais pas si tu veux la première occurence de chaque onglet ou
toutes les occurences de chaque onglet?

Sub cherche_premiere_occur_chque_onglet()
Dim mot As String, s As Worksheet, c As Range
mot = InputBox("Mot cherché?")
If mot = "" Then Exit Sub
For Each s In ActiveWorkbook.Sheets ' tous les onglets
s.Select
Set c = Cells.Find(mot)
If Not c Is Nothing Then
c.Interior.ColorIndex = 36
End If
Next s
Sheets(1).Select
End Sub

Le pgm ci dessous colorie TOUTES les occurences de chaque onglet:

Sub cherche_tous_onglets()
Dim mot As String, s As Worksheet, c As Range
mot = InputBox("Mot cherché?")
If mot = "" Then Exit Sub
For Each s In ActiveWorkbook.Sheets
s.Select
Set c = Cells.Find(mot)
If Not c Is Nothing Then
premier = c.Address
Do
c.Interior.ColorIndex = 4
Set c = Cells.FindNext(c)
Loop Until c Is Nothing Or c.Address = premier
End If
Next s
Sheets(1).Select
End Sub

Cordialement JB