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 42 43
|
Private Sub CommandButton1_Click()
Dim cellulecherche As Range
Dim ligne, i, g As Integer
Dim firstadress As String
With Worksheets(ComboBox1.Value)
lig = 1
Set cellulecherche = .Range(Cells(lig, 2), Cells(1000, 2)).Find(what:="*" & TextBox1 & "*", LookIn:=xlValues)
If cellulecherche Is Nothing Then
firstadress = cellulecherche.Address
'MsgBox ("Aucun produit ne correspond à votre recherche")
Do
ligne = (cellulecherche.Row)
Sheets("Recherche").Cells(100, 2).End(xlUp).Offset(1, 0) = Sheets(ComboBox1.Value).Cells(ligne, 2).Value
Sheets("Recherche").Cells(100, 1).End(xlUp).Offset(1, 0) = cellulecherche.Offset(0, -1).End(xlUp).Value
Set cellulecherche =. Range(Cells(lig, 2), Cells(1000, 2)).FindNext(cellulecherche)
Loop While Not cellulecherche Is Nothing And cellulecherche.Address <> firstAddress
End If
'On affiche les critères de recherche sur le feuille "Recherche" :
Sheets("Recherche").Cells(9, 2) = ComboBox1.Value
Sheets("Recherche").Cells(10, 2) = ComboBox2.Value
Sheets("Recherche").Cells(11, 2) = TextBox1.Value
'On se place dans la feuille "Recherche" pour visualiser les résultats :
Sheets("Recherche").Select
Unload UserForm1
End With
End Sub |
Partager