IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Recherche d'une date dans une ListBox


Sujet :

Macros et VBA Excel

  1. #1
    Membre du Club
    Homme Profil pro
    Urbaniste
    Inscrit en
    Février 2017
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Albanie

    Informations professionnelles :
    Activité : Urbaniste
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Février 2017
    Messages : 6
    Par défaut Recherche d'une date dans une ListBox
    Bonjour tous le monde ,
    veuillez m'aider à simplifier ce code qui recherche une date dans une listbox de 12 colonnes en sélectionnant
    les critères ( >,< ,ou = ) de la combobox2 .
    le code :
    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
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    Private Sub CommandButton5_Click() 'Search Button
    Dim sat, s As Long
    Dim deg1, deg2 As String
    If TextBox13.Value = "" Then
    MsgBox "Please enter a value", vbExclamation
    TextBox13.SetFocus
    Exit Sub
    End If
    With Application
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    .EnableEvents = False
    End With
     
    If ComboBox1.Value = "" Or ComboBox1.Value = "-" Then
    MsgBox "Choose a filter field", vbExclamation
    ComboBox1.SetFocus
    Exit Sub
    End If
    For a = 1 To 12 ' Clear textboxes(1-12)
    Controls("textbox" & a) = ""
    Next
    With ListBox1
    .Clear
    .ColumnCount = 12
    .ColumnWidths = "92;140;110;65;65;35;40;65;65;115;150;65"
    End With
    Call Main 'Progress Bar
     
    deg2 = TextBox13.Value
    Select Case ComboBox1.Value
    Case "DATE"
    Select Case ComboBox2.ListIndex
    Case "0"
    For sat = 2 To Cells(65536, "E").End(xlUp).Row
    Set deg1 = Cells(sat, "E")
    If UCase(deg1) Like UCase(deg2) & "*" Then
    ListBox1.AddItem
    ListBox1.List(s, 0) = Cells(sat, "A")
    ListBox1.List(s, 1) = Cells(sat, "B")
    ListBox1.List(s, 2) = Cells(sat, "C")
    ListBox1.List(s, 3) = Cells(sat, "D")
    ListBox1.List(s, 4) = Cells(sat, "E")
    ListBox1.List(s, 5) = Cells(sat, "F")
    ListBox1.List(s, 6) = Cells(sat, "G")
    ListBox1.List(s, 7) = Cells(sat, "H")
    ListBox1.List(s, 8) = Cells(sat, "I")
    ListBox1.List(s, 9) = Cells(sat, "J")
    ListBox1.List(s, 10) = Cells(sat, "K")
    ListBox1.List(s, 11) = Cells(sat, "L")
    s = s + 1
    End If: Next
    Case "1"
    For sat = 2 To Cells(65536, "E").End(xlUp).Row
    Set deg1 = Cells(sat, "E")
    If UCase(deg1) < UCase(deg2) & "*" Then
    ListBox1.AddItem
    ListBox1.List(s, 0) = Cells(sat, "A")
    ListBox1.List(s, 1) = Cells(sat, "B")
    ListBox1.List(s, 2) = Cells(sat, "C")
    ListBox1.List(s, 3) = Cells(sat, "D")
    ListBox1.List(s, 4) = Cells(sat, "E")
    ListBox1.List(s, 5) = Cells(sat, "F")
    ListBox1.List(s, 6) = Cells(sat, "G")
    ListBox1.List(s, 7) = Cells(sat, "H")
    ListBox1.List(s, 8) = Cells(sat, "I")
    ListBox1.List(s, 9) = Cells(sat, "J")
    ListBox1.List(s, 10) = Cells(sat, "K")
    ListBox1.List(s, 11) = Cells(sat, "L")
    s = s + 1
    End If: Next
    Case "2"
    For sat = 2 To Cells(65536, "E").End(xlUp).Row
    Set deg1 = Cells(sat, "E")
     
    If UCase(deg1) > UCase(deg2) & "*" Then
    ListBox1.AddItem
    ListBox1.List(s, 0) = Cells(sat, "A")
    ListBox1.List(s, 1) = Cells(sat, "B")
    ListBox1.List(s, 2) = Cells(sat, "C")
    ListBox1.List(s, 3) = Cells(sat, "D")
    ListBox1.List(s, 4) = Cells(sat, "E")
    ListBox1.List(s, 5) = Cells(sat, "F")
    ListBox1.List(s, 6) = Cells(sat, "G")
    ListBox1.List(s, 7) = Cells(sat, "H")
    ListBox1.List(s, 8) = Cells(sat, "I")
    ListBox1.List(s, 9) = Cells(sat, "J")
    ListBox1.List(s, 10) = Cells(sat, "K")
    ListBox1.List(s, 11) = Cells(sat, "L")
    s = s + 1
    End If: Next
    End Select
    With Application
    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
    .EnableEvents = True
    End With
         Label15.Caption = ListBox1.ListCount
    End Sub
    MERCI

  2. #2
    Expert confirmé
    Homme Profil pro
    aucune
    Inscrit en
    Avril 2016
    Messages
    7 563
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 83
    Localisation : France, Pyrénées Atlantiques (Aquitaine)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Avril 2016
    Messages : 7 563
    Par défaut
    Bonjour
    "veuillez" ? Veuillez est un ordre... et je n'aime pas obéir.
    Je reconsidèrerai ma position lorsque ta demande d'aide sera formulée différemment et que tu auras su donner à ton titre une rédaction autre (résumé d'une difficulté).

  3. #3
    Membre du Club
    Homme Profil pro
    Urbaniste
    Inscrit en
    Février 2017
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Albanie

    Informations professionnelles :
    Activité : Urbaniste
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Février 2017
    Messages : 6
    Par défaut
    Je ne pensait pas que veuillez m'aider .... avec un grand MERCI à la fin est un ordre .
    Merci une second fois d'avoir pris la peine de venir aimablement à mon aide .

Discussions similaires

  1. [XL-2007] Besoin d'aide pour simplifier le code répétitif
    Par Nomorerulz dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 17/05/2016, 23h41
  2. Aide pour simplifier un code et comprendre le mécanisme
    Par nicdodo dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 02/04/2015, 16h50
  3. Demande d'aide pour code
    Par sonic1 dans le forum C
    Réponses: 1
    Dernier message: 07/03/2009, 17h29
  4. Aide pour simplifier un code VBA Excel
    Par NEC14 dans le forum Macros et VBA Excel
    Réponses: 19
    Dernier message: 24/01/2008, 17h15
  5. Demande d'aide pour un problème de code source sur devC++
    Par Rickantonais dans le forum Débuter
    Réponses: 28
    Dernier message: 01/08/2007, 15h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo