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
| Private Sub CommandButton8_Click()
Dim MotCherche, plage As range, Cell As range, range As range, c As Variant
MotCherche = Me.TextBox1.Text
Dim colonnerecherche As String
Dim owbk As Workbook
Set owbk = Workbooks.Open("D:\BIT PAPIER\ENREGISTREMENT.xls")
If ActiveWorkbook.ReadOnly = True Then
ActiveWorkbook.Close False
Exit Sub
End If
'On lance la recherche sur la colonne ColonneRecherche
With Worksheets(1).range("L1:L500")
Set c = .Find(MotCherche, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then 'donnée trouvée
'On place les données de la ligne dans les textbox
Me.TextBox48.Value = Cells(c.Row, 8).Value
Me.TextBox49.Value = Cells(c.Row, 9).Value
Me.TextBox50.Value = Cells(c.Row, 10).Value
Me.TextBox51.Value = Cells(c.Row, 11).Value
'Voici mon probléme !!!!
Do
Set c = .FindNext(MotCherche, after:=c, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
Loop While
End If
MotCherche = Me.TextBox1.Text
If MotCherche = "" Then
MsgBox "Tapez le nom pour commencer la recherche", _
vbCritical, " - Manque nom - "
End If
ActiveWorkbook.Save
ActiveWorkbook.Close
Exit Sub
End Sub |
Partager