evolution macro

J

jerems

Guest
Bonjour,

Voici ma question:

J'ai 2 onglets: 1 avec une liste d'entreprises et 1 autre avec 1 bouton auquel est donné une macro qui me permet d'aller à une entreprise de la liste que j'au indiqué en A2 dans le deuxième onglet.
Mon problème: je voudrais atteindre cette case mais j'aimerias qu'elle s'affiche en haut de l'écran. Pouvez-vous m'aider?

Cidesous la macro:

Sub Recherche()
Dim motcle As Variant
Dim fin As Integer
Dim liste As Variant
Dim c As Variant
Dim first As Integer
With Sheets(1)
' ______Test si la liste est vide ou non
If .Range('A2').Value = '' Then
MsgBox ('La liste est vide')
End
Else
fin = .Range('A2').End(xlDown).Row
liste = 'A2:A' & fin
End If
End With
With Sheets(2)
motcle = .Range('A2').Value
If motcle = '' Then
MsgBox ('Aucun mot clé n'a été donné')
End
End If
End With
'_____________________________________________________________
With Sheets(1).Range(liste)
Set c = .Find(motcle, LookIn:=xlValues)
If Not c Is Nothing Then

first = c.Row
End If
End With
Sheets(1).Select
Range('a' & first).Select

End Sub

Merci
 

Bebere

XLDnaute Barbatruc
bonjour Jerems
le code changé
Sub Recherche()
Dim motcle As Variant
Dim fin As Integer
Dim liste As Variant
Dim c As Variant
Dim first As Integer
With Sheets(1)
' ______Test si la liste est vide ou non
If .Range('A2').Value = '' Then
MsgBox ('La liste est vide')
Exit Sub
Else
fin = .Range('A65536').End(xlUp).Row
liste = 'A2:A' & fin
End If
End With
With Sheets(2)
motcle = .Range('A2').Value
If motcle = '' Then
MsgBox ('Aucun mot clé n'a été donné')
Exit Sub
End If
End With
'_____________________________________________________________
With Sheets(1).Range(liste)
Set c = .Find(motcle, LookIn:=xlValues)
If Not c Is Nothing Then
first = c.Row
End If
End With
Application.Goto Reference:=Sheets(1).Range('a' & first), _
scroll:=True
End Sub
à bientôt
 

Robert

XLDnaute Barbatruc
Repose en paix
Bonjour Jerems, Bebere, bonjour le forum,

Bebere m'a encore grillé sur ce coup... Je te donne quand même ma proposition Jerems:


Sub Recherche()
Dim motcle As String
Dim fin As Integer
Dim liste As Range
Dim c As Range
Dim first As Integer

With Sheets(1)
' ______Test si la liste est vide ou non
If .Range('A2').Value = '' Then
MsgBox ('La liste est vide')
Exit Sub
Else
fin = .Range('A2').End(xlDown).Row
Set liste = .Range('A2:A' & fin)
End If
End With

With Sheets(2)
motcle = .Range('A2').Value
If motcle = '' Then
MsgBox ('Aucun mot clé n'a été donné')
Exit Sub
End If
End With

'_____________________________________________________________
With liste
Set c = .Find(motcle, LookIn:=xlValues)
If Not c Is Nothing Then
first = c.Row
End If
End With
Sheets(1).Select
c.Select
ActiveWindow.ScrollRow = first
End Sub
 

Discussions similaires

Réponses
2
Affichages
298

Statistiques des forums

Discussions
312 467
Messages
2 088 679
Membres
103 918
dernier inscrit
comite des fets allonzier