Tri par date via combobox

Bonjour à tous

J'ai un formulaire dans lequel j'affiche mes données et je dispose d'un comboxbox pour choisir les dates.

J'aimerais quand je choisis une date dans le combobox qu'il m'affiche uniquement les données avec la date choisie.

Merci d'avance à tous

bonne journée

11test.xlsm (296.13 Ko)

Salut Netparty

Voici une possibilité

Private Sub ComboBox1_Change()
  Dim Ind As Long, Col As Long
  ' Si saisie vide
  If Me.ComboBox1 = "" Then Call UserForm_initialize : Exit Sub
  ' Sinon
  ' Colonne des dates
  Col = Range("AM1").Column - 1
  ' Pour chaque ligne de la ListBox de la fin au début
  For Ind = ListBox1.ListCount - 1 To 0 Step -1
    ' Si la date est différente
    If Me.ListBox1.List(Ind, Col) <> DateValue(Me.ComboBox1) Then
      ' supprimer la ligne
      Me.ListBox1.RemoveItem (Ind)
    End If
  Next Ind
End Sub

@+

Bonjour BrunoM45

Merci pour ton code.

La recherche par date fonctionne nickel, mais si je choisi l’astérisque pour tout ré afficher j'ai un message d'erreur

Re,

Pas fait gaffe qu'il y avait un astérisque... Ah ces sacrés Gaulois

A tester

Private Sub ComboBox1_Change()
  Dim Ind As Long, Col As Long
  ' Si saisie vide
  If Me.ComboBox1 = "*" Then Call UserForm_initialize : Exit Sub
  ' Sinon
  ' Colonne des dates
  Col = Range("AM1").Column - 1
  ' Pour chaque ligne de la ListBox de la fin au début
  For Ind = ListBox1.ListCount - 1 To 0 Step -1
    ' Si la date est différente
    If Me.ListBox1.List(Ind, Col) <> DateValue(Me.ComboBox1) Then
      ' supprimer la ligne
      Me.ListBox1.RemoveItem (Ind)
    End If
  Next Ind
End Sub

@+

Re BrunoM45

Plus de bug pour "*", par contre au premier choix de date j'ai bien les données et si ensuite je choisi une autre date je n'ai plus rien d'afficher

Rechercher des sujets similaires à "tri date via combobox"