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
|
Function TrouverValeur(ByVal ValeurATrouver As Integer, ByVal Position As String) As Variant
Dim Cellule As Range, AireDeRechercheGauche As Range, AireDeRechercheDroite As Range
Application.Volatile
TrouverValeur = ""
With ActiveSheet
Set AireDeRechercheGauche = .Range("X5,X9,X15,X19,X26,X30,X36,X40,AA7,AA17,AA28,AA38")
Set AireDeRechercheDroite = .Range("P7,P17,P28,P38,L9,L19,L30,L40,AD12,AD33,H14,H35,D18,D39")
If UCase(Mid(Position, 1, 1)) = "G" Then
For Each Cellule In AireDeRechercheGauche
If Cellule = ValeurATrouver Then
TrouverValeur = Cellule.Offset(-1, -1)
End If
Next Cellule
Else
For Each Cellule In AireDeRechercheDroite
If Cellule = ValeurATrouver Then
TrouverValeur = Cellule.Offset(-1, 1)
End If
Next Cellule
End If
End With
Set AireDeRechercheGauche = Nothing
Set AireDeRechercheDroite = Nothing
End Function |
Partager