voici le code de la macro:
Sub Remplissage()
'****** PARAMETRES ******
wm = ActiveWorkbook.Name
Sheets('TOTAL').Select
activite = Cells(2, 2).Value
fichier = Cells(58, 2).Value
rep = Cells(59, 2).Value
'Ouverture du fichier
Workbooks.Open rep & fichier
tri_nom_activite_date
'****** On parcourt les onglets du fichier wm ******
Workbooks(wm).Activate
numfeuille = 1
While numfeuille < Worksheets.Count
Sheets(numfeuille).Select
nomcc = ActiveSheet.Name
If IsNumeric(nomcc) Then
Else
'recherche du nom conseiller dans le fichier BD
Workbooks(fichier).Activate
ligne = 2
trouve = 0
While Cells(ligne, 1).Value <> '' And trouve < 2
If Cells(ligne, 1).Value = nomcc And Cells(ligne, 19).Value = activite Then
trouve = 1
'on remplit les infos
ddj = Cells(ligne, 18).Value
i = 7
trouvedate = 0
While Workbooks(wm).Worksheets(nomcc).Cells(i, 1).Value <> '' And trouvedate = 0
If Workbooks(wm).Worksheets(nomcc).Cells(i, 1).Value = ddj Then
trouvedate = 1
Else
i = i + 1
End If
Wend
If trouvedate = 1 Then
'appels ACD
Workbooks(wm).Worksheets(nomcc).Cells(i, 2).Value = Cells(ligne, 2).Value
'DM appel ACD en mn
Workbooks(wm).Worksheets(nomcc).Cells(i, 3).Value = Cells(ligne, 3).Value
'Temps moyen ACW en mn
Workbooks(wm).Worksheets(nomcc).Cells(i, 4).Value = Cells(ligne, 4).Value
'Durée moy MEA en mn
Workbooks(wm).Worksheets(nomcc).Cells(i, 5).Value = Cells(ligne, 15).Value
'Temps connecté
Workbooks(wm).Worksheets(nomcc).Cells(i, 6).Value = Cells(ligne, 11).Value / 3600
'Temps sonnerie agent
Workbooks(wm).Worksheets(nomcc).Cells(i, 8).Value = Cells(ligne, 7).Value
'Temps dispo
Workbooks(wm).Worksheets(nomcc).Cells(i, 12).Value = Cells(ligne, 10).Value / 3600
'Transferts sortants
Workbooks(wm).Worksheets(nomcc).Cells(i, 14).Value = Cells(ligne, 13).Value
'Appels MEA
Workbooks(wm).Worksheets(nomcc).Cells(i, 15).Value = Cells(ligne, 14).Value
End If
End If
If trouve = 1 And Cells(ligne, 1).Value <> nomcc Then
'si on a déjà trouvé le nomcc et qu on ne le trouve plus, alors
'ca veut dire qu on est plus sur le conseiller donc on sort
trouve = 2
End If
ligne = ligne + 1
Wend
End If
Workbooks(wm).Activate
numfeuille = numfeuille + 1
Wend
Workbooks(fichier).Close savechanges:=0
End Sub