Rechercher dans tout le classeur sauf un onglet
Bonjour, j ai mis une macro recherche dans tout le classeur avec le code suivant, mais j ai un onglet ou il y a le recapitulatif de toutes mes donnees, et j aimerais eviter de rechercher dans cette page.
j espere que c est possible, et je vous en remercie d avance de votre s avoir ^^
cordialement
Sub rechercherdansclasseur()
'Sub RechercherNom()
Dim Sh As Worksheet
Dim c As Range
Dim Nom As String, firstAddress As String
Nom = InputBox("Référence à chercher dans toutes les feuilles du classeur", "Rechercher")
If Nom <> "" Then
For Each Sh In ThisWorkbook.Worksheets
Set c = Sh.Cells.Find(Nom) 'xlpart = partie du nom
If Not c Is Nothing Then
Sh.Activate
c.Select
firstAddress = c.Address
Do
strreponse = MsgBox(Sh.Name & "!" & c.Address & vbCrLf & _
"Oui pour continuer la recherche" & vbLf & _
"Non pour sortir", vbYesNo)
If strreponse = vbNo Then Exit Sub
Set c = Sh.Cells.FindNext(c)
c.Select
Loop While Not c Is Nothing And c.Address <> firstAddress
Set c = Nothing
End If
Next Sh
End If
End Sub
f
Bonjour,
For Each Sh In ThisWorkbook.Worksheets
if Sh.Name<>"Récapitulatif" Then ....
A+
re, et merci frangy de ta reponse.
cependant, je l ai place et ca me met une erreur, l ais je bien place ?
cordialement
Sub rechercherdansclasseur()
'Sub RechercherNom()
Dim Sh As Worksheet
Dim c As Range
Dim Nom As String, firstAddress As String
Nom = InputBox("Référence à chercher dans toutes les feuilles du classeur", "Rechercher")
If Nom <> "" Then
For Each Sh In ThisWorkbook.Worksheets
if Sh.Name<>"toutes ref" Then
Set c = Sh.Cells.Find(Nom) 'xlpart = partie du nom
If Not c Is Nothing Then
Sh.Activate
c.Select
firstAddress = c.Address
Do
strreponse = MsgBox(Sh.Name & "!" & c.Address & vbCrLf & _
"Oui pour continuer la recherche" & vbLf & _
"Non pour sortir", vbYesNo)
If strreponse = vbNo Then Exit Sub
Set c = Sh.Cells.FindNext(c)
c.Select
Loop While Not c Is Nothing And c.Address <> firstAddress
Set c = Nothing
End If
Next Sh
End If
End Sub
f
Bonsoir,
Il manquait une fin de branchement conditionnel (End If).
Pour éviter ce type de problème, efforce-toi d'indenter correctement ton code.
Sub rechercherdansclasseur()
Dim Sh As Worksheet
Dim c As Range
Dim Nom As String, firstAddress As String
Dim strreponse As Integer
Nom = InputBox("Référence à chercher dans toutes les feuilles du classeur", "Rechercher")
If Nom <> "" Then
For Each Sh In ThisWorkbook.Worksheets
If Sh.Name <> "toutes ref" Then
Set c = Sh.Cells.Find(Nom) 'xlpart = partie du nom
If Not c Is Nothing Then
Sh.Activate
c.Select
firstAddress = c.Address
Do
strreponse = MsgBox(Sh.Name & "!" & c.Address & vbCrLf & _
"Oui pour continuer la recherche" & vbLf & _
"Non pour sortir", vbYesNo)
If strreponse = vbNo Then Exit Sub
Set c = Sh.Cells.FindNext(c)
c.Select
Loop While Not c Is Nothing And c.Address <> firstAddress
Set c = Nothing
End If
End If
Next Sh
End If
End Sub
A+
un grand merci a toi, et desole de ne pas etre de grand pro comme vous.
cordialement