2009-10-19 10 views

Répondre

12
Dim rng As Range 

Set rng = Selection.Find(What:=email, After:=ActiveCell, LookIn:=xlFormulas, _ 
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ 
    False, SearchFormat:=False) 

If Not rng Is Nothing Then 'when rng <> nothing means found something' 
    rng.Activate 
End IF 
2

Find renvoie un objet Range qui aura la valeur Nothing si What est introuvable. De l'aide:

With Worksheets(1).Range("a1:a500") 
    Set c = .Find(2, lookin:=xlValues) 
    If Not c Is Nothing Then 
     firstAddress = c.Address 
     Do 
      c.Value = 5 
      Set c = .FindNext(c) 
     Loop While Not c Is Nothing And c.Address <> firstAddress 
    End If 
End With 
1

Selection.Find est comme utiliser Ctrl + F pour trouver une valeur. Vous pouvez ensuite vérifier par rapport à Activecell.Value pour voir si vous avez obtenu le résultat souhaité.

Questions connexes