1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Function EstCompatible(ID, Employes As Range, Compatibilites As Range) As Double
Dim i As Long: i = 1
Dim j As Long: j = 1
Dim nbcol As Integer
Dim habLigne As Range, HabColonne As Range
nbcol = Employes.Columns.Count
Set habLigne = Compatibilites.Offset(0).Resize(1)
Set HabColonne = Compatibilites.Resize(, 1)
EstCompatible = 0
Do While i <= Employes.Rows.Count
If Employes(i, 1).Value = ID Then
j=i+1
Do While j <= Employes.Rows.Count
If Employes(j, 1).Value = ID Then
EstCompatible = EstCompatible + Application.Index(Compatibilites, _
Application.Match(Employes(i, nbcol).Value, HabColonne, 0), _
Application.Match(Employes(j, nbcol).Value, habLigne, 0))
End If
j = j + 1
Loop
End If
i = i + 1
j = 1
Loop
End Function |
Partager