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

Un souci de date

3 réponses
Avatar
Apitos
Bonsoir =E0 tous,

En voulant appliquer un filtre automatique =E0 mon tableau dans la feuille =
"Base" (WS1) pour extraire des donn=E9es entre deux dates, j=92obtiens un r=
=E9sultat nulle, pourtant il y a bien une ligne qui correspond =E0 mon filt=
re :

'--------------------------------------------------------
date_debut =3D Date - Application.Choose(Application.Weekday(Date, 2), =
5, 6, 0, 1, 2, 3, 4)
date_fin =3D date_debut + 6
With WS1
If .AutoFilterMode =3D False Then .Range("A7:F7").AutoFilter
.Range("A7:F7").AutoFilter Field:=3D3, Criteria1:=3D">=3D" & Format=
(date_debut, "dd/mm/yyyy") _
, Operator:=3DxlAnd, Criteria2:=3D"<=3D" &=
Format(date_fin, "dd/mm/yyyy")
End With
Set Rng =3D [_filterdatabase].Resize(, 6).SpecialCells(xlCellTypeVisibl=
e)
Clgn =3D [_filterdatabase].Resize(, 1).SpecialCells(xlCellTypeVisible).=
Count - 1
MsgBox "Count lignes =3D " & Clgn
'-------------------------------------------------------------

Date_d=E9but =3D 16/05/2012 ; Date_fin =3D 22/05/2012

Mais la date contenu dans le tableau est sous la forme :=20

16/05/2012 11:24:00

Y a-t-il un probl=E8me dans le format de la date ?

Merci.

3 réponses

Avatar
isabelle
bonsoir Apitos,

essai avec le format 0 ou Standard

Criteria1:=">=" & Format(date_debut, "0")

--
isabelle



Le 2012-05-17 18:54, Apitos a écrit :
Bonsoir à tous,

En voulant appliquer un filtre automatique à mon tableau dans la feuille "Base" (WS1)



pour extraire des données entre deux dates, j’obtiens un résultat nulle, pourtant il y a bien une ligne qui correspond à mon filtre :

'--------------------------------------------------------
date_debut = Date - Application.Choose(Application.Weekday(Date, 2), 5, 6, 0, 1, 2, 3, 4)
date_fin = date_debut + 6
With WS1
If .AutoFilterMode = False Then .Range("A7:F7").AutoFilter
.Range("A7:F7").AutoFilter Field:=3, Criteria1:=">="& Format(date_debut, "dd/mm/yyyy") _
, Operator:=xlAnd, Criteria2:="<="& Format(date_fin, "dd/mm/yyyy")
End With
Set Rng = [_filterdatabase].Resize(, 6).SpecialCells(xlCellTypeVisible)
Clgn = [_filterdatabase].Resize(, 1).SpecialCells(xlCellTypeVisible).Count - 1
MsgBox "Count lignes = "& Clgn
'-------------------------------------------------------------

Date_début = 16/05/2012 ; Date_fin = 22/05/2012

Mais la date contenu dans le tableau est sous la forme :

16/05/2012 11:24:00

Y a-t-il un problème dans le format de la date ?

Merci.
Avatar
isabelle
ou plutot avec cette correction,

Dim date_debut As Long, date_fin As Long
date_debut = Date - Application.Choose(Application.Weekday(Date, 2), 5, 6, 0, 1, 2, 3, 4)
date_fin = date_debut + 6
With WS1
If .AutoFilterMode = False Then .Range("A7:F7").AutoFilter
.Range("A7:F7").AutoFilter Field:=3, Criteria1:=">=" & date_debut _
, Operator:=xlAnd, Criteria2:="<=" & date_fin
End With
Set Rng = [_filterdatabase].Resize(, 6).SpecialCells(xlCellTypeVisible)
Clgn = [_filterdatabase].Resize(, 1).SpecialCells(xlCellTypeVisible).Count - 1
MsgBox "Count lignes = " & Clgn

--
isabelle



Le 2012-05-17 19:47, isabelle a écrit :
bonsoir Apitos,

essai avec le format 0 ou Standard

Criteria1:=">=" & Format(date_debut, "0")

Avatar
Apitos
Bonsoir Isabelle,

Les deux solutions donnent un résultat.

Merci bien.