[VBA] Trouver le numéro de la ligne d'une cellule

powergirl

XLDnaute Nouveau
Bonjour,

J'ai deux feuille Bdd et configuration.
Quand j’insère une donné dans la feuille configuration via un userform, je veux trouver le numéro de la ligne de cette valeur dans la feuille Bdd
Voici mon code qui me retourne toujours nothing.

Merci

Private Sub valider_Click()
Dim nombre As Integer
Dim i As Integer

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim wb As Workbook
Dim ws As Worksheet
Dim FoundCell As Range
Set wb = ActiveWorkbook
Set ws = Sheets("Bdd")
Dim Valeur_recherche
Dim bloc
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

i = 1
nombre = quantite().Value

While i <= nombre

If ActiveCell.Value = "" Then
ActiveCell.Value = Me.reference 'Me.reference vient d'une ListBox

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Valeur_recherche = Me.reference

Set FoundCell = ws.Range("D4:D2000").Find(What:=Valeur_recherche)
If Not FoundCell Is Nothing Then
MsgBox (Valeur_recherche & "est à la ligne: " & FoundCell.Row)
Else
MsgBox (Valeur_recherche & " n'existe pas")
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Else
Rows(ActiveCell.Row + i).Insert Shift:=xlDown 'xlUp

Cells(ActiveCell.Row + i, "C") = Me.reference
' Set PlageDeRecherche = Sheets("Bdd").Range("D2:D2000")
'Valeur_Cherchee = Me.reference
'
'
' Trouve = PlageDeRecherche.Cells.Find(What:=Valeur_Cherchee, LookAt:=xlWhole)
' f2.Cells(ActiveCell.Row + i, "D") = Sheets("Bdd").Range("I" & Trouve).Value
' Set c = Sheets("Bdd").Range("D4:D200").Find(Me.reference, LookIn:=xlValues)
' therow = c.Row
' f2.Cells(ActiveCell.Row + i, "D") = Sheets("Bdd").Range("I" & therow).Value


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Valeur_recherche = Me.reference

Set FoundCell = ws.Range("D4:D2000").Find(What:=Valeur_recherche)
If Not FoundCell Is Nothing Then
MsgBox (Valeur_recherche & " est à la ligne: " & FoundCell.Row)



Else
MsgBox (Valeur_recherche & "n'existe pas")
End If

i = i + 1
End If

Wend

' Set cel = Cells.Find(what:=Me.reference)
'Ligne1 = cel.Row 'pour renvoyer le numéro de ligne
'f2.Cells(ActiveCell.Row + i, "D") = Sheets("Bdd").Range("B" & Ligne1).Value
Unload Me
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 104
Messages
2 085 332
Membres
102 864
dernier inscrit
abderrashmaen