module de recherche

A

Armel

Guest
Salut le forum,


J'ai fait un module de recherche sur une feuille Excel.

Sub Recherche()

ActiveSheet.Cells.Find(What:=Worksheets(2).[C13], After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select

mémo1 = ActiveCell.Interior.ColorIndex
mémo2 = ActiveCell.Font.Size
mémo3 = ActiveCell.Font.Color
mémo4 = ActiveCell.Font.Bold
For i = 1 To 1
Application.Wait Now + TimeValue("00:00:01")
ActiveCell.Interior.Color = RGB(27, 27, 255)
ActiveCell.Font.Color = RGB(255, 255, 255)
ActiveCell.Font.Bold = True
Application.Wait Now + TimeValue("00:00:01")
ActiveCell.Interior.Color = RGB(27, 27, 255)
ActiveCell.Font.Color = RGB(255, 255, 255)
ActiveCell.Font.Bold = True

Next i
ActiveCell.Interior.ColorIndex = mémo1
ActiveCell.Font.Size = mémo2
ActiveCell.Font.Color = mémo3
ActiveCell.Font.Bold = mémo4

End Sub


Lorsque le module a trouvé le mot que j'ai tapé dans la cellule C13, il clignot.
Jusque là pas de probleme. Mais si je tape un mot qui n'existe pas, la fenetre de deboguage s'ouvre. Est ce que quelqu'un pourrai m'aider pour qu'il affiche "ce mot n'existe pas dans cette feuille".


Merci à tous les programmeurs
 
M

Munchkin

Guest
Bonjour Armel

essais ca

Sub Recherche()

Dim reponse As Variant
On Error GoTo Erreur

ActiveSheet.Cells.Find(What:=Worksheets(2).[C13], After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select

mémo1 = ActiveCell.Interior.ColorIndex
mémo2 = ActiveCell.Font.Size
mémo3 = ActiveCell.Font.Color
mémo4 = ActiveCell.Font.Bold
For i = 1 To 1
Application.Wait Now + TimeValue("00:00:01")
ActiveCell.Interior.Color = RGB(27, 27, 255)
ActiveCell.Font.Color = RGB(255, 255, 255)
ActiveCell.Font.Bold = True
Application.Wait Now + TimeValue("00:00:01")
ActiveCell.Interior.Color = RGB(27, 27, 255)
ActiveCell.Font.Color = RGB(255, 255, 255)
ActiveCell.Font.Bold = True

Next i
ActiveCell.Interior.ColorIndex = mémo1
ActiveCell.Font.Size = mémo2
ActiveCell.Font.Color = mémo3
ActiveCell.Font.Bold = mémo4

GoTo Fin

Erreur:
ChMessage = "ce mot n'existe pas dans cette feuille."
reponse = MsgBox(ChMessage, vbCritical, TITREBOITE, Err.HelpFile, Err.HelpContext)

Fin:
End Sub

Cordialement
Munchkin
 

Membres actuellement en ligne

Statistiques des forums

Discussions
314 144
Messages
2 106 357
Membres
109 563
dernier inscrit
sylla121