bonjour a tous,
je viens vers vous pour que vous m aidiez, j'ai vraiment besoin de votre aide
je veux faire une recherche de ce mot "ON" à une date donnée et qui me comptabilise le nombre de fois que se repète ce mot "ON" à
cette date.
EXPLE:
si j'entre 26/11/2012 il doit affcher dans msgbox le mot ON se répète n nombre de fois ou
si j'entre 22/11/2012 il doit afficher dans msgbox le mot ON se répète n nombre de fois
je vous joint un fichier
j'a essayé avec ce code mais ça ne marche pas:
/*****************************************************/
Sub calcule()
Dim resultat As Date
Application.ScreenUpdating = False
resultat = InputBox("Entrer la date recherchée au format JJ/MM/AAAA", "titre")
mot1 = resultat
mot2 = "---- ON ----"
Cpte = 0
Dim tab1 'Crée une variable
Set tab1 = CreateObject("Scripting.Dictionary")
'-------------------------------------------------------------
'recherche de la date et mémorisation
'-------------------------------------------------------------
For Each Sh In Worksheets
Sheets(Sh.Name).Select
With ActiveWorkbook.Worksheets(Sh.Name).Cells
Set Sch = .Find(CStr(mot1), LookIn:=xlValues)
If Not Sch Is Nothing Then
cle = Sh.Name & "_l" & Sch.Row
tab1(cle) = 1 ' mémorise feuille, ligne
End If
End With
Next
'-------------------------------------------------------------
'recherche du mot2 et verification si existance de la date
'-------------------------------------------------------------
For Each Sh In Worksheets
Sheets(Sh.Name).Select
With ActiveWorkbook.Worksheets(Sh.Name).Cells
Set Sch = .Find(CStr(mot2), LookIn:=xlValues)
If Not Sch Is Nothing Then
cle = Sh.Name & "_l" & Sch.Row
firstAddress = Sch.Address
If tab1.exists(cle) Then
Do
Set Sch = .FindNext(Sch)
Cpte = Cpte + 1
Loop While Not Sch Is Nothing And Sch.Address <> firstAddress
End If
End If
End With
Next Sh
Application.ScreenUpdating = True
MsgBox ("le mot ON se répète : " & Cpte )
End Sub
/*********************************************************************************/
cordialement
David