Recherche sur deux feuilles différentes

olhey

XLDnaute Occasionnel
Bonjour,

Au début de mon projet j'avais 2feuilles, maintenant j'en ai 3...

voici le code qu'il ya sur une:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim Cellule As Range
    If Target.Column = 3 Then
        If Target.Value <> "" Then
            With [COLOR="Red"]Worksheets("Km 0-20").[/COLOR]Range("D49:AY113")
                Set Cellule = .Find(What:=Target.Value, After:=[COLOR="red"]Worksheets("Km 0-20").[/COLOR]Range("D49"), LookIn:=xlFormulas, LookAt _
                    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                    False, SearchFormat:=False)
                If Cellule Is Nothing Then Exit Sub
                Cancel = True
                Application.Goto Cellule
            End With
        End If
    End If
End Sub

ainsi lorsque je double cliquait sur une cellule, il le cherchais son contenu dans la feuil(km 0-20) et m'y ammenait.
Maintenant j'ai une nouvelle feuille(km 21-41), il faut que j'adapte le script pour qu'il cherche non seulement dans la feuil1 1 mais aussi dans l'autre.(la zone(de cellule) de recherche est la même sur les 2 feuilles.

Merci de votre aide! ça me sauve. :)
 

skoobi

XLDnaute Barbatruc
Re : Recherche sur deux feuilles différentes

Bonjour olhey,

A tester:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim Cellule As Range
    If Target.Column = 3 Then
        If Target.Value <> "" Then
            With Worksheets("Km 0-20").Range("D49:AY113")
                Set Cellule = .Find(What:=Target.Value, After:=Worksheets("Km 0-20").Range("D49"), LookIn:=xlFormulas, LookAt _
                    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                    False, SearchFormat:=False)
            End With
            If Cellule Is Nothing Then
                With Worksheets("Km 21-41").Range("D49:AY113")
                    Set Cellule = .Find(What:=Target.Value, After:=Worksheets("Km 21-41").Range("D49"), LookIn:=xlFormulas, LookAt _
                        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                        False, SearchFormat:=False)
                End With
                If Cellule Is Nothing Then Exit Sub
            End If
            Cancel = True
            Application.Goto Cellule
        End If
    End If
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 579
Messages
2 089 880
Membres
104 298
dernier inscrit
MarieCB