Function MFC(cel As Range, plage As Range) As Boolean
If Not IsNumeric(CStr(cel)) Then Exit Function
Dim n1#, lig&, tablo, u1&, u2%, lig1&, lig2&, d As Object
Dim i&, k%, n2#, t$, flag As Boolean, j&
n1 = CDbl(cel)
lig = cel.Row - plage.Row + 1
tablo = plage 'matrice plus rapide
u1 = UBound(tablo)
u2 = UBound(tablo, 2)
lig1 = IIf(lig = 1, 2, lig - 1)
lig2 = lig1 + IIf(lig = 1 Or lig = u1, 0, 2)
'---création de Dictionary---
Set d = CreateObject("Scripting.Dictionary")
For i = lig1 To lig2 Step 2
For k = 1 To u2
If IsNumeric(CStr(tablo(i, k))) Then
n2 = CDbl(tablo(i, k))
t = Application.Min(n1, n2) & " " & Application.Max(n1, n2)
d(t) = t
End If
Next
Next
'---test avec Dictionary---
For i = 1 To u1
If i <> lig Then
flag = False
For k = 1 To u2
If IsNumeric(CStr(tablo(i, k))) Then
If CDbl(tablo(i, k)) = n1 Then flag = True: Exit For
End If
Next
If flag Then
lig1 = IIf(i = 1, 2, i - 1)
lig2 = lig1 + IIf(i = 1 Or i = u1, 0, 2)
For j = lig1 To lig2 Step 2
For k = 1 To u2
If IsNumeric(CStr(tablo(j, k))) Then
n2 = CDbl(tablo(j, k))
t = Application.Min(n1, n2) & " " & Application.Max(n1, n2)
If d.Exists(d(t)) Then MFC = True: Exit Function
End If
Next
Next
End If
End If
Next
End Function