Bonjour à tous,
dans le code ci-dessous, je voudrais filtrer une colonne par la variable ART. J'y arrive partiellement dans 2 cas sur 3 possible.
La même chaine de carractères (ex: 6300) saisie dans l'imput box peut apparaitre sous trois formes différentes:
a- 6300
b- nombre(6300)
c- 6300(nombre)
Les parenthèses sont toujours présentes seul le nombre change.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 CommandButton22_Click() Dim ART As String Application.ScreenUpdating = False On Error Resume Next ActiveSheet.ShowAllData ART = InputBox("Saisir le numéro d'article avec * s'il faut") If ART <> "" Then ActiveSheet.Range("$A$6:$AP$5000").AutoFilter Field:=2, Criteria1:=ART _ , Operator:=xlOr, Criteria2:="=*(" & ART & ")" 'Tri commande VAI croissant et tri of croissant ActiveWorkbook.Worksheets("Données").AutoFilter.Sort.SortFields.Clear ActiveWorkbook.Worksheets("Données").AutoFilter.Sort.SortFields.Add2 Key:= _ Range("G6:G3618"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _ :=xlSortNormal With ActiveWorkbook.Worksheets("Données").AutoFilter.Sort .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With ActiveWorkbook.Worksheets("Données").AutoFilter.Sort.SortFields.Clear ActiveWorkbook.Worksheets("Données").AutoFilter.Sort.SortFields.Add2 Key:= _ Range("E6:E3618"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _ :=xlSortNormal With ActiveWorkbook.Worksheets("Données").AutoFilter.Sort .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With Application.ScreenUpdating = True Application.Goto Range("A1"), True End Sub
Partager