Filtre d'apres choix combobox non vide

carlos

XLDnaute Impliqué
Supporter XLD
Bonjour

cette macro (clic bouton) me lance un USF qui filtre une bdd (f_ele).

Chaque combobox fait reference à une colonne et à un critere ( un peu comme les filtres)

Le probleme est que si un des combobox est vide il recherche les cellules vides comme condition repondant a ce combobox alors que je voudrais qu'il ne tienne pas compte de ce ou ces combobox vides ..;

Merci
 

carlos

XLDnaute Impliqué
Supporter XLD
Re bebere

Ne devrait il pas y avoir des ' and' entre chaque filtrage pour garder en memoire la premiere condition ????????

If ChoixCombo1 <> '' Then
Ws1.Cells.AutoFilter Field:=4, Criteria1:=ChoixCombo1
AND
ElseIf ChoixCombo2 <> '' Then
Ws1.Cells.AutoFilter Field:=5, Criteria1:=ChoixCombo2
and
ElseIf MyValue = 3 Then
Ws1.Cells.AutoFilter Field:=6, Criteria1:=ChoixCombo3
and
ElseIf ChoixCombo4 <> '' Then
Ws1.Cells.AutoFilter Field:=7, Criteria1:=ChoixCombo4
and
ElseIf ChoixCombo5 <> '' Then
Ws1.Cells.AutoFilter Field:=8, Criteria1:=ChoixCombo5

??????????????????????????

ou faut il passer par une collection à chaque filtre ???,

carlos
 
B

bebere

Guest
re
tu m'as mis sur une idée
tester sur une autre variable que choixcombo1,choixcombo2....
ajouté choix1,choix2,etc.....
à+ :S [file name=ClasseoptionV2_20050823145935.zip size=50578]http://www.excel-downloads.com/components/com_simpleboard/uploaded/files/ClasseoptionV2_20050823145935.zip[/file]
 

Pièces jointes

  • ClasseoptionV2_20050823145935.zip
    49.4 KB · Affichages: 27
B

bebere

Guest
re
été trop vite dans mes conclusions
il suffit d'écrire le if sur une ligne
If ChoixCombo1 <> '' Then Ws1.Cells.AutoFilter Field:=4, Criteria1:=ChoixCombo1
If ChoixCombo2 <> '' Then Ws1.Cells.AutoFilter Field:=5, Criteria1:=ChoixCombo2
If ChoixCombo3 <> '' Then Ws1.Cells.AutoFilter Field:=6, Criteria1:=ChoixCombo3
If ChoixCombo4 <> '' Then Ws1.Cells.AutoFilter Field:=7, Criteria1:=ChoixCombo4
If ChoixCombo5 <> '' Then Ws1.Cells.AutoFilter Field:=8, Criteria1:=ChoixCombo5
Field:=4
à+ :S
 

Discussions similaires

Réponses
12
Affichages
546

Statistiques des forums

Discussions
312 330
Messages
2 087 344
Membres
103 525
dernier inscrit
gbaipc