Bonjour,

j ai une textbox, style boite de recherche, qui me sert lorsque j'insert une donnée de filtrer les info dans un autre fichier excel sans l'ouvrir .
Le probleme c'est que j'ai un message d'erreur au niveau du selection autofilter.
Quelqu'un aurait une idée...merci


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
Private Sub TextBox1_Change()
 
Dim appxl As Excel.Application
Dim fichier As Window
Dim feuille As Worksheet
Set appxl = CreateObject("Excel.application")
Dim read As Variant
 
With appxl
    .Workbooks.Open "U:\Release\Nomenc\DCS-MF\GESTION_DES_MT\liste_MTG_DS.xls"
    .Visible = False
End With
 
Set fichier = appxl.Windows("liste_MTG_DS.xls")
            fichier.Activate
            Set feuille = appxl.Sheets("MT")
 
Selection.AutoFilter 
Selection.AutoFilter Field:=1, Criteria1:=TextBox1.Value, Operator:=xlOr, _
       Criteria2:="=*" & TextBox1.Value & "*"
 
 
appxl.Workbooks("liste_MTG_DS.xls").Save
appxl.Workbooks("liste_MTG_DS.xls").Close
 
End Sub