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
   |  
Function Fonction_Trouver_Ligne(Feuille_Ou_Effectuer_La_Recherche As Worksheet, _
                                Colonne_De_Recherche As Integer, _
                                Valeur_A_Rechercher As String) As Long
 
    Dim Trouve As Range
 
    'Initialiser la fonction
    'Fonction_Trouver_Ligne = 0 '<<-pas nécessaire, toujours égale à 0 en début d'appel
 
    With Feuille_Ou_Effectuer_La_Recherche
 
        'Rechercher la string dans la colonne voulue avec correspondance exacte
        'xlWhole=recherche stricte
        'xlPart=recherche partielle
        Set Trouve = .Columns(Colonne_De_Recherche).Find(Valeur_A_Rechercher, , xlValues, xlWhole)
 
        'si correspondance exacte
        If Not Trouve Is Nothing Then
            Fonction_Trouver_Ligne = Trouve.Row
        End If
 
    End With
 
End Function | 
Partager