Function MOY(txt As String) As Variant
'calcule les moyennes
Dim w As Worksheet, ref As Range, test As Boolean, n As Byte
Application.Volatile
On Error Resume Next
For Each w In Worksheets
If w.Name <> "Récapitulatif" Then 'à adapter
Set ref = w.Cells.Find(txt, , xlValues, xlWhole)
If Not ref Is Nothing Then
If ref.Offset(, -1) <> "" Then
'test pour repérer les erreurs
test = ref.Offset(, -1) < 1 Or ref.Offset(, -1) > 9
If test Or Err Then MOY = "Voir " & w.Name: Exit Function
n = n + 1
MOY = MOY + ref.Offset(, -1)
End If
End If
End If
Next
MOY = MOY / n
End Function