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
|
Function QuelleCorrespondance(ByVal Age As Integer, ByVal Metier As String, ByVal Sexe As String) As String
Dim lngDerniereLigne As Long
Dim intDerniereColonne As Integer
Dim oPlage As Range
Dim oMetier As Range
Dim I As Integer
Dim strCorrespondance As String
Range("C1").Select
intDerniereColonne = ActiveCell.SpecialCells(xlCellTypeLastCell).Column
Range("A2").Select
lngDerniereLigne = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
Set oPlage = Range(Cells(2, 1), Cells(lngDerniereLigne, 1))
For Each oMetier In oPlage
If oMetier.Value = Metier Then
If oMetier.Offset(0, 1).Value = Sexe Then
For I = oMetier.Column To intDerniereColonne
If Cells(1, I).Value = Age Then
strCorrespondance = oMetier.Offset(0, I - 1).Value
End If
Next
End If
End If
Next
If Len(strCorrespondance) = 0 Then
strCorrespondance = "Aucune correspondance"
End If
QuelleCorrespondance = strCorrespondance
End Function
Sub cmdObtenirValeur()
Dim intAge As Integer, strMetier As String, strSexe As String
intAge = txtAge
strMetier = txtMetier
strSexe = txtSexe
MsgBox QuelleCorrespondance(intAge, strMetier, strSexe)
End Sub |
Partager