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
| Function Min_MultiCriteres(Champ As Range, Compare As Range) As Double
Const DEFAUT As Double = 99999999999# 'on fixe, par défaut, le minimum à une très grande valeur
Dim var
Dim T()
Dim i&
Dim j&
Dim A$
Dim Mini#
'---
var = Champ
ReDim T(1 To UBound(var, 1), 1 To 2)
'---
For i& = 1 To UBound(var, 1)
For j& = 1 To UBound(var, 2)
T(i&, 1) = T(i&, 1) & Trim(CStr(var(i&, j&)))
Next j&
T(i&, 2) = var(i&, UBound(var, 2))
Next i&
'---
var = Compare
For j& = 1 To UBound(var, 2)
A$ = A$ & var(1, j&)
Next j&
'---
Mini# = DEFAUT
For i& = 1 To UBound(T, 1)
If Mid(T(i&, 1), 1, Len(A$)) = A$ Then
If IsNumeric(T(i&, 2)) Then
If T(i&, 2) < Mini# Then Mini# = T(i&, 2)
End If
End If
Next i&
If Mini# <> DEFAUT Then Min_MultiCriteres = Mini#
End Function |
Partager