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 44
| Private Sub TextBoxproduitcherche_Exit(ByVal Cancel As MSForms.ReturnBoolean)'c'est un textbox pour les criteres de recherche
Dim cel As Range, ERREUR As Integer
Application.ScreenUpdating = False
With sheets("references")'c'est ma feuille
If .AutoFilterMode Then
.AutoFilterMode = False
End If
ERREUR = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("b2").AutoFilter
.Range("b2").AutoFilter Field:=2, Criteria1:="*" & TextBoxproduitcherche & "*"
Set PLAGE = .Range("b2", .Range("b2").End(xlDown))
Set PLAGE = PLAGE.Cells.SpecialCells(xlCellTypeVisible)
If PLAGE.Count > ERREUR Then
If .AutoFilterMode Then
.AutoFilterMode = False
MsgBox "AUCUN CRITERE NE CORRESPOND A LA RECHERCHE"
Exit Sub
End If
End If
With REFCHOISIE 'c'est ma listbox
.Clear
'et toi tu fais ce que tu veux
For Each cel In PLAGE
.AddItem cel(1, 0)
.Column(1, .ListCount - 1) = cel(1, 1)
.Column(2, .ListCount - 1) = VBA.Format(cel(1, 2), "#,##0.00 ")
.Column(3, .ListCount - 1) = VBA.Format(cel(1, 3), "#0.00 %")
.Column(4, .ListCount - 1) = cel(1, 5)
.Column(5, .ListCount - 1) = VBA.Format(cel(1, 6), "#0.00")
.Column(6, .ListCount - 1) = VBA.Format(cel(1, 8), "# ##0.00 ")
.Column(7, .ListCount - 1) = VBA.Format(cel(1, 9), "##0")
.BoundColumn = 1
Next cel
End With
Selection.AutoFilter
.Select
If .AutoFilterMode Then
.AutoFilterMode = False
End If
End With
Application.ScreenUpdating = True
End Sub |
Partager