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 :

probleme recherche multicritere


Sujet :

Macros et VBA Excel

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Août 2010
    Messages
    1 019
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Août 2010
    Messages : 1 019
    Par défaut probleme recherche multicritere
    Bonjour à tous,

    J'ai crée une base de données sur excel avec des userform.
    Il y a le nom, prenom, fonction, structure et adresse de la personne qui fais une formation chez nous. Jusque là tout va bien!
    J'aimerais faire un userform avec une recherche multicritere.(J'ai mis une petite image pour exemple).
    Et j'ai trouvé un code sur internet mais je n'arrive pas à l'adapter pour moi car je pense que là personne utilisait une version plus récente car j'ai un probleme avec listview.
    Donc je l'ai remplacé par une listbox danc mon cas mais ça ne marche pas...si quelqu'un pouvait m'aider, merci et bonne soirée

    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
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    module1
     
    Option Explicit
    Option Compare Text
     
    Public Cl(12) As Integer                    ' Colonne de recherche
    Public Ch(12) As String  
     
    Sub Recherche()
    Dim Ws As Worksheet
    Dim H As Integer
    Dim I As Integer
    Dim J As Long
    Dim K As Integer
     
    Dim Nok As Boolean
     
      Set Ws = Sheets("Fonds d'Investissement")
     
      'Définition de la plage de recherche sur la feuille
      With UserForm1
        'Vide le contenu de la listview
        .ListView1.ListItems.Clear
        For J = 4 To Ws.Range("B" & Ws.Rows.Count).End(xlUp).Row
        Nok = False
          For I = 1 To 12
            If Not Cells(J, Cl(I)) Like Ch(I) & "*" Then
              Nok = True
              Exit For
            End If
          Next I
          If Nok = False Then
            With .ListView1
              .ListItems.Add , , Ws.Cells(J, "B")
              H = .ListItems.Count
              For K = 3 To 10
                .ListItems(H).ListSubItems.Add , , Ws.Cells(J, K)
              Next K
            End With
          End If
        Next J
        .ListView1.SetFocus
      End With
    End Sub
     
     
     
    userform8
     
    Option Explicit
     
    Dim Init As Boolean
     
    Private Sub ComboBox1_Change()
    ' Activités
      If Init = True Then Exit Sub
      Cl(1) = IIf(Me.ComboBox1.ListIndex = -1, 255, 11 + Me.ComboBox1.ListIndex)
      Ch(1) = IIf(Me.ComboBox1.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub ComboBox2_Change()
    'Zone géographique
      If Init = True Then Exit Sub
      Cl(2) = IIf(Me.ComboBox2.ListIndex = -1, 255, 15 + Me.ComboBox2.ListIndex)
      Ch(2) = IIf(Me.ComboBox2.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub ComboBox3_Change()
    'Préférence géographique
      If Init = True Then Exit Sub
      Cl(3) = IIf(Me.ComboBox3.ListIndex = -1, 255, 20 + Me.ComboBox3.ListIndex)
      Ch(3) = IIf(Me.ComboBox3.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub ComboBox4_Change()
    'Préférence sectorielles
      If Init = True Then Exit Sub
      Cl(4) = IIf(Me.ComboBox4.ListIndex = -1, 255, 23 + Me.ComboBox4.ListIndex)
      Ch(4) = IIf(Me.ComboBox4.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub ComboBox5_Change()
    'Cible en CA / Effectifs                  *************************
      If Init = True Then Exit Sub
      Cl(5) = 30
      Ch(5) = Me.ComboBox5
      Recherche
    End Sub
     
    Private Sub ComboBox6_Change()
    'Phase de l'investissement
      If Init = True Then Exit Sub
      Cl(6) = IIf(Me.ComboBox6.ListIndex = -1, 255, 31 + Me.ComboBox6.ListIndex)
      Ch(6) = IIf(Me.ComboBox6.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub ComboBox7_Change()
    'Prise de participation
      If Init = True Then Exit Sub
      Cl(7) = IIf(Me.ComboBox7.ListIndex = -1, 255, 37 + Me.ComboBox7.ListIndex)
      Ch(7) = IIf(Me.ComboBox7.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub ComboBox8_Change()
    'Durée des prises de participation        *************************
      If Init = True Then Exit Sub
      Cl(8) = 39
      Ch(8) = Me.ComboBox8
      Recherche
    End Sub
     
    Private Sub ComboBox9_Change()
    'Modalités de sortie
      If Init = True Then Exit Sub
      Cl(9) = IIf(Me.ComboBox9.ListIndex = -1, 255, 40 + Me.ComboBox9.ListIndex)
      Ch(9) = IIf(Me.ComboBox9.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub ComboBox10_Change()
    'Investissement moyen                     *************************
      If Init = True Then Exit Sub
      Cl(10) = 43
      Ch(10) = Me.ComboBox10
      Recherche
    End Sub
     
    Private Sub ComboBox11_Change()
    'Processus de traitement des dossiers
      If Init = True Then Exit Sub
      Cl(11) = IIf(Me.ComboBox11.ListIndex = -1, 255, 44 + Me.ComboBox11.ListIndex)
      Ch(11) = IIf(Me.ComboBox11.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub ComboBox12_Change()
    'Durée moyenne d'instruction
      If Init = True Then Exit Sub
      Cl(12) = IIf(Me.ComboBox12.ListIndex = -1, 255, 49 + Me.ComboBox12.ListIndex)
      Ch(12) = IIf(Me.ComboBox12.ListIndex = -1, "", "X")
      Recherche
    End Sub
     
    Private Sub UserForm_Initialize()
    Dim I As Integer
    Dim Lg As Long
    Dim Ws As Worksheet
     
      Set Ws = Sheets("Listes")
      Init = True
      For I = 1 To 12
        Me.Controls("Label" & I) = Ws.Cells(1, I)
        With Me.Controls("ComboBox" & I)
          .Clear
          For Lg = 2 To Ws.Cells(Rows.Count, I).End(xlUp).Row
            .Value = Ws.Cells(Lg, I)
            If .ListIndex = -1 Then
              .AddItem Ws.Cells(Lg, I)
            End If
          Next Lg
          .ListIndex = -1
        End With
      Next I
      Set Ws = Sheets("Fonds d'Investissement")
      With Me.ListView1
        'Titres des colonnes
        With .ColumnHeaders
          .Clear
          'Ajout des colonnes
          .Add , , "Organisme", 95, lvwColumnLeft             ' Organisme
          .Add , , "Adresse", 75, lvwColumnCenter             ' Adresse
          .Add , , "Bureaux", 75, lvwColumnCenter             ' Bureaux
          .Add , , "Téléphone", 75, lvwColumnCenter           ' Téléphone
          .Add , , "Mail", 75, lvwColumnCenter                ' Mail
          .Add , , "Site", 65, lvwColumnCenter                ' Site internet
          .Add , , "Dirigeants", 65, lvwColumnCenter          ' Menbres dirigeants
          .Add , , "Contacts", 95, lvwColumnCenter            ' Contacts entrepeneurs
          .Add , , "Parts", 75, lvwColumnCenter               ' Parts de l'activité capital développement
     
        End With
        .View = lvwReport                                     ' Affichage en mode Rapport
        .Gridlines = True                                     ' Affichage d'un quadrillage
        .FullRowSelect = True                                 ' Sélection des lignes complètes
        .LabelEdit = lvwManual                                ' Modifications interdites
      End With
      For I = 1 To 12
        Cl(I) = 255
        Ch(I) = ""
      Next I
      Recherche
      Init = False
    End Sub
    Images attachées Images attachées  

Discussions similaires

  1. Réponses: 13
    Dernier message: 22/06/2010, 16h08
  2. probleme recherche multicritere
    Par Miss kouka dans le forum Langage
    Réponses: 1
    Dernier message: 11/06/2010, 14h12
  3. [AC-2007] Probleme formulaire recherche multicritere
    Par seb10l dans le forum IHM
    Réponses: 4
    Dernier message: 26/05/2009, 18h38
  4. Réponses: 6
    Dernier message: 05/01/2006, 14h09
  5. Recherche multicritere
    Par beLz dans le forum Requêtes
    Réponses: 3
    Dernier message: 02/09/2005, 18h24

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