Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Critères FiltreAutomatique VBA

3 réponses
Avatar
LydieT
Bonjour.
Dans VBA je sais récupérer le ou les 2 critères de filtrage.
Mais je ne sais pas récupérer la liste complète du choix des critères d'une
colonne. Ets-ce Possible ????
Merci.

3 réponses

Avatar
JB
Bonjour,

http://boisgontierjacques.free.fr/pages_site/FiltreAuto.htm" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://boisgontierjacques.free.fr/pages_site/FiltreAuto.htm

Function FiltreTotal()
Application.Volatile
feuille = ActiveSheet.Name
'feuille = Application.Caller.Parent.Name
chaine = ""
For c = 1 To Sheets(feuille).Range("_FilterDataBase").Columns.Count
If FiltreActuelNo(c) <> "" Then
If IsDate(Sheets(feuille).Range("_FilterDataBase").Cells(2, c))
Then
chaine = chaine &
Sheets(feuille).Range("_FilterDataBase").Cells(1, c) &
FiltreActuelNo(c, "D") & " "
Else
chaine = chaine &
Sheets(feuille).Range("_FilterDataBase").Cells(1, c).Value &
FiltreActuelNo(c) & " "
End If
End If
Next c
If chaine = "" Then chaine = "Tout"
FiltreTotal = chaine
End Function

Function FiltreActuelNo(col, Optional typeCol As String)
feuille = ActiveSheet.Name ' Application.Caller.Parent.Name
Application.Volatile
If Sheets(feuille).FilterMode Then
If Sheets(feuille).AutoFilter.Filters.Item(col).On Then
temp = Sheets(feuille).AutoFilter.Filters.Item(col).Criteria1
If Left(temp, 2) = ">=" Or Left(temp, 2) = "<=" Then
o = Left(temp, 2): n = Mid(temp, 3)
Else
If Left(temp, 1) = "=" Or Left(temp, 1) = ">" Or Left(temp,
1) = "<" Then
o = Left(temp, 1): n = Mid(temp, 2)
Else
n = temp
End If
End If
If typeCol = "D" Then n = Format(n, "dd/mm/yy")
temp = o & n
'---
If Sheets(feuille).AutoFilter.Filters.Item(col).Operator Then
oper =
IIf(Sheets(feuille).AutoFilter.Filters.Item(col).Operator = 1, " ET ",
" OU ")
On Error Resume Next
Err = 0
temp2 =
Sheets(feuille).AutoFilter.Filters.Item(col).Criteria2
If Err = 0 Then
If Left(temp2, 2) = ">=" Or Left(temp2, 2) = "<=" Then
o = Left(temp2, 2): n = Mid(temp2, 3)
Else
If Left(temp2, 1) = "=" Or Left(temp2, 1) = ">" Or
Left(temp2, 1) = "<" _
Then o = Left(temp2, 1): n = Mid(temp2, 2)
End If
If typeCol = "D" Then n = Format(n, "dd/mm/yy")
temp2 = o & n
Else
oper = ""
End If
End If
FiltreActuelNo = temp & oper & temp2
Else
FiltreActuelNo = ""
End If
Else
FiltreActuelNo = ""
End If
End Function

JB
http://boisgontierjacques.free.fr/


On 21 juin, 11:51, LydieT wrote:
Bonjour.
Dans VBA je sais récupérer le ou les 2 critères de filtrage.
Mais je ne sais pas récupérer la liste complète du choix des crit ères d'une
colonne. Ets-ce Possible ????
Merci.


Avatar
LydieT
JB wrote in
news::
Wouaaa...
Bon je vais essayer merci.....
Bonjour,

http://boisgontierjacques.free.fr/pages_site/FiltreAuto.htm" target="_blank" class="text-blue hover:opacity-90 " style="word-break: break-all;" rel="noopener nofollow">http://boisgontierjacques.free.fr/pages_site/FiltreAuto.htm

Function FiltreTotal()
Application.Volatile
feuille = ActiveSheet.Name
'feuille = Application.Caller.Parent.Name
chaine = ""
For c = 1 To Sheets(feuille).Range("_FilterDataBase").Columns.Count
If FiltreActuelNo(c) <> "" Then
If IsDate(Sheets(feuille).Range("_FilterDataBase").Cells(2, c))
Then
chaine = chaine &
Sheets(feuille).Range("_FilterDataBase").Cells(1, c) &
FiltreActuelNo(c, "D") & " "
Else
chaine = chaine &
Sheets(feuille).Range("_FilterDataBase").Cells(1, c).Value &
FiltreActuelNo(c) & " "
End If
End If
Next c
If chaine = "" Then chaine = "Tout"
FiltreTotal = chaine
End Function

Function FiltreActuelNo(col, Optional typeCol As String)
feuille = ActiveSheet.Name ' Application.Caller.Parent.Name
Application.Volatile
If Sheets(feuille).FilterMode Then
If Sheets(feuille).AutoFilter.Filters.Item(col).On Then
temp = Sheets(feuille).AutoFilter.Filters.Item(col).Criteria1
If Left(temp, 2) = ">=" Or Left(temp, 2) = "<=" Then
o = Left(temp, 2): n = Mid(temp, 3)
Else
If Left(temp, 1) = "=" Or Left(temp, 1) = ">" Or Left(temp,
1) = "<" Then
o = Left(temp, 1): n = Mid(temp, 2)
Else
n = temp
End If
End If
If typeCol = "D" Then n = Format(n, "dd/mm/yy")
temp = o & n
'---
If Sheets(feuille).AutoFilter.Filters.Item(col).Operator Then
oper
IIf(Sheets(feuille).AutoFilter.Filters.Item(col).Operator > 1, " ET ",
" OU ")
On Error Resume Next
Err = 0
temp2 Sheets(feuille).AutoFilter.Filters.Item(col).Criteria2
If Err = 0 Then
If Left(temp2, 2) = ">=" Or Left(temp2, 2) = "<=" Then
o = Left(temp2, 2): n = Mid(temp2, 3)
Else
If Left(temp2, 1) = "=" Or Left(temp2, 1) = ">" Or
Left(temp2, 1) = "<" _
Then o = Left(temp2, 1): n = Mid(temp2, 2)
End If
If typeCol = "D" Then n = Format(n, "dd/mm/yy")
temp2 = o & n
Else
oper = ""
End If
End If
FiltreActuelNo = temp & oper & temp2
Else
FiltreActuelNo = ""
End If
Else
FiltreActuelNo = ""
End If
End Function

JB
http://boisgontierjacques.free.fr/


On 21 juin, 11:51, LydieT wrote:
Bonjour.
Dans VBA je sais récupérer le ou les 2 critères de filtrage.
Mais je ne sais pas récupérer la liste complète du choix des crit
ères d'une

colonne. Ets-ce Possible ????
Merci.







Avatar
Ellimac
Bonjour,

Normalement la liste proposée correspond à la liste des éléments du champ
sans doublons. Donc tu peux utiliser le filtre élaboré sans doublons sur ton
champ pour l'obtenir.

Camille

"LydieT" wrote:

Bonjour.
Dans VBA je sais récupérer le ou les 2 critères de filtrage.
Mais je ne sais pas récupérer la liste complète du choix des critères d'une
colonne. Ets-ce Possible ????
Merci.