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
| Function OPTIONCELLULE(Cellule1 As Variant, Plage1 As Range, Colonne1 As Integer) As Variant
If Application.CountIf(Plage1.Columns(1), Cellule1.Value) > 0 Then
Dim Resultat1 As String
Dim Boucle1 As Integer
For Boucle1 = 1 To 10000
If Plage1(Boucle1, 1) = Cellule1 Then
Resultat1 = Resultat1 & "/" & Plage1(Boucle1, Colonne1)
End If
Next Boucle1
Else
Resultat1 = "xAucune correspondance"
End If
OPTIONCELLULE = Right(Resultat1, Len(Resultat1) - 1)
End Function
Function OPTIONCHAINE(Cellule2 As Variant, Plage2 As Range, Colonne2 As Integer) As Variant
If Application.CountIf(Plage2.Columns(1), "*" & Cellule2.Value & "*") > 0 Then
Dim Resultat2 As String
Dim Boucle2 As Integer
For Boucle2 = 1 To 10000
Chaine = "*" & Cellule2.Value & "*"
If Plage2(Boucle2, 1) Like Chaine Then
Resultat2 = Resultat2 & "/" & Plage2(Boucle2, Colonne2)
End If
Next Boucle2
Else
Resultat2 = "xAucune correspondance"
End If
OPTIONCHAINE = Right(Resultat2, Len(Resultat2) - 1)
End Function
Function RECHERCHE1POURN(Cellule3 As Variant, Plage3 As Range, Colonne3 As Integer, I As Integer) As Variant
Dim Resultat3 As String
If I = 1 Then
Resultat3 = OPTIONCHAINE(Cellule3, Plage3, Colonne3)
ElseIf I = 0 Then
Resultat3 = OPTIONCELLULE(Cellule3, Plage3, Colonne3)
Else
Resultat3 = "Erreur argument"
End If
RECHERCHE1POURN = Resultat3
End Function |
Partager