' MonDico par JB
Function JacKrauser(PlageType As Range, PlageDate As Range, MonType As String, MaDate As String, MaPosition As Byte) As String
Dim MonDico, I As Integer, Désignations, Nombres, J As Byte
If PlageType.Columns.Count > 1 Or PlageDate.Columns.Count > 1 Or PlageType.Count <> PlageDate.Count Then
JacKrauser = "Erreur!"
Exit Function
End If
Set MonDico = CreateObject("Scripting.Dictionary")
For I = 1 To PlageType.Count
If PlageDate(I) = MaDate Then
Select Case MonType
Case "X", "Y"
If Left(PlageType(I), 1) = MonType Then
MonDico(PlageType(I).Value) = MonDico(PlageType(I).Value) + 1
End If
Case Else
If Left(PlageType(I), 1) <> "X" And Left(PlageType(I), 1) <> "Y" Then
MonDico(PlageType(I).Value) = MonDico(PlageType(I).Value) + 1
End If
End Select
End If
Next I
Désignations = MonDico.Keys
Nombres = MonDico.Items
For J = 1 To MaPosition
For I = LBound(Désignations) To UBound(Désignations)
If Nombres(I) = Application.WorksheetFunction.Large(Nombres, 1) Then
JacKrauser = Désignations(I)
Nombres(I) = 0
Exit For
End If
Next I
Next J
End Function