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 TextBoxproduitcherche_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim cel As Range, ERREUR As Integer
Application.ScreenUpdating = False
With Sheets("references")
If .AutoFilterMode Then
.AutoFilterMode = False
End If
ERREUR = .Range("b2").End(xlDown).Offset(0, 0).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
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