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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| Public Function max_clasind(myrange As Range) As String
Dim Arr(), valr(), best() As Integer 'Tableau contenant toutes les valeurs de la cellule choisie
Dim i, j, k, m, n As Integer
Dim com As String
m = 1
ReDim Arr(1 To myrange.Count * Worksheets.Count, 3)
For j = 1 To Worksheets.Count
Set myrange = Worksheets(j).Range(myrange.Address)
For i = 1 To myrange.Count
Arr(m, 3) = myrange.Cells(i).Value
Arr(m, 1) = Worksheets(j).Name
Arr(m, 2) = Worksheets(j).Range("B5:B27").Cells(i).Value
m = m + 1
Next i
Next j
ReDim valr(1 To myrange.Count * Worksheets.Count)
For k = 1 To myrange.Count * Worksheets.Count
valr(k) = Arr(k, 3)
Next k
n = 1
For i = LBound(Arr, 3) To UBound(Arr, 3)
If Arr(3, i) = Application.Max(valr) Then
best(n) = Arr(1, i) & Arr(2, i) & Arr(3, i)
n = n + 1
End If
Next i
max_clasind = best(1)
End Function |
Partager