Public Function CodePays(Code As String) As String
Static Cn As Object
If Cn Is Nothing Then
Set Cn = CreateObject("Adodb.Connection")
Cn.Open (GenereCSTRING(Xls, Base:=ThisWorkbook.FullName))
End If
Const SQL As String = "SELECT [F3],[F1] FROM [pays$] WHERE [F2]=?"
Const SQL1 As String = "SELECT [F7],[F5] FROM [pays$] WHERE [F6]=?"
Dim T() As String, I As Integer
T = Split(Replace(Replace(Code, Chr(160), Chr(32)), "-", Chr(32)))
For I = UBound(T) To LBound(T) Step -1
If Len(T(I)) < 4 Then
With ExecuteRequete(SQL, Cn, "P", UCase(T(I)))
If Not .EOF Then
CodePays = .Getstring(, , "|")
.Close
Exit For
End If
.Close
End With
With ExecuteRequete(SQL1, Cn, "P", UCase(Left(T(I), 2)))
If Not .EOF Then
CodePays = .Getstring(, , "|")
.Close
Exit For
End If
.Close
End With
End If
Next
If CodePays = "" Then CodePays = "-?-"
End Function