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 multiple en une fois


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre actif
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Décembre 2012
    Messages : 30
    Par défaut Recherche multiple en une fois
    Bonjour et bonne année a tous

    Bon d'habitude je n'ai pas beaucoup de chance car on ne repond pas beaucoup a mes questions, j'espere que celle ci sera la bonne

    J'ai un usf de recherche avec textbox et listbox j'aimerai savoir comment on fait pour que dans le texbox je puisse mettre ma recherche a la suite
    exemple: au lieu de taper la reference 50410 et m'afficher le tout dans la listbox pouvoir mettre toute mes recherches en une fois
    exemple : 50410;14652;21547;87985.... tout ça pour gagner du temps et avoir le tout afiché dans la listbox

    Merci a vous .

    voici mon code ( si en meme temps quelqu'un pouvais juste regarder mon probleme pour modifier les lignes pour que ca les modifies dans mon classeur ca serait genial )

    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
    Option Base 1
     
     
     
    Private Sub CommandButton1_Click()
    With Sheets("Clients")
      DerLg = .Range("A" & .Rows.Count).End(xlUp).Row
      .Range("A" & DerLg + 1) = TextBoxfor
      .Range("B" & DerLg + 1) = TextBoxdes
      .Range("C" & DerLg + 1) = ComboBoxcon
      .Range("D" & DerLg + 1) = TextBoxlot
      .Range("E" & DerLg + 1) = TextBoxqua
      .Range("F" & DerLg + 1) = CDate(TextBoxfab)
      .Range("G" & DerLg + 1) = CDate(TextBoxfin)
      .Range("H" & DerLg + 1) = ComboBoxzon
      .Range("I" & DerLg + 1) = TextBoxall
      .Range("J" & DerLg + 1) = TextBoxcom
      .Range("K" & DerLg + 1) = TextBox7
      .Range("L" & DerLg + 1) = TextBox5
      Set plg = .Range("A2:L" & .Range("A" & .Rows.Count).End(xlUp).Row)
      plg.Columns.AutoFit
      Me.Width = ListBox1.Width + 20
      TbEntier = plg
    End With
    End Sub
     
    Private Sub CommandButton2_Click()
    Dim DerLig As Long
      If MsgBox("Voulez vous modifier l'article ?", 36, "Création") = vbYes Then
     
        DerLig = Sheets("Feuil3").Range("A65000").End(xlUp).Row + 1
     
        Range(Cells(DerLig - 1, 1), Cells(DerLig - 1, 40)).Copy
        Cells(DerLig, 1).PasteSpecial Paste:=xlPasteFormats
        Application.CutCopyMode = False
     
     
            Sheets("Feuil3").Cells(DerLig, 1) = TextBoxfor.Value
            Sheets("Feuil3").Cells(DerLig, 2) = TextBoxdes.Value
            Sheets("Feuil3").Cells(DerLig, 3) = ComboBoxcon.Value
            Sheets("Feuil3").Cells(DerLig, 4) = TextBoxlot.Value
            Sheets("Feuil3").Cells(DerLig, 5) = TextBoxqua.Value
            Sheets("Feuil3").Cells(DerLig, 6) = CDate(TextBoxfab.Value)
            Sheets("Feuil3").Cells(DerLig, 7) = CDate(TextBoxfin.Value)
            'Sheets("Feuil3").Cells(DerLig, 8) = ComboBoxzon.Value
            Sheets("Feuil3").Cells(DerLig, 8) = TextBoxall.Value
            Sheets("Feuil3").Cells(DerLig, 9) = ComboBoxlig
            Sheets("Feuil3").Cells(DerLig, 10) = CDate(TextBoxcon.Value)
     
      End If
     
     
     
     
    End Sub
     
    Private Sub CommandButton4_Click()
    Unload Me
    End Sub
     
    Private Sub CommandButton5_Click()
        Me.ListBox1.RemoveItem Me.ListBox1.ListIndex
    End Sub
     
     
     
    Private Sub CommandButton6_Click()
    '
    ' effacer Macro
    ' efface les cellule de la feuille planning
    '
     
    '
        Range("A2:J1519").Select
        Selection.ClearContents
    End Sub
     
    Private Sub Label1_Click()
     
    End Sub
     
    Private Sub TextBoxcom_Change()
     
    End Sub
     
    Private Sub TextBoxrec_Change()
    Dim S As String, i As Long, L As Long, Nbr As Long, k As Long
    Dim tbPartiel()
    nbrecol = 12
    If TextBoxrec = "" Then
      ListBox1.List = TbEntier
    Else
    L = 1
      ReDim Preserve tbPartiel(UBound(TbEntier, 1), nbrecol)
      For i = 1 To UBound(TbEntier, 1)
        For k = 1 To nbrecol
          If UCase(TbEntier(i, k)) Like "*" & UCase(TextBoxrec) & "*" Then
            For Nbr = 1 To 12
              tbPartiel(L, Nbr) = TbEntier(i, Nbr)
            Next Nbr
            L = L + 1
            Exit For
          End If
        Next k
      Next i
      Me.Repaint
      ListBox1.List = tbPartiel
    End If
    End Sub
     
     
     
     
    Private Sub UserForm_Initialize()
    Dim cw
    With Sheets("Clients")
      Set plg = .Range("A2:L" & .Range("A" & .Rows.Count).End(xlUp).Row)
      plg.Columns.AutoFit
      ListBox1.Width = 20 + plg.Width
      Me.Width = ListBox1.Width + 20
      TbEntier = plg
    End With
    With ListBox1
      cw = ""
      .ColumnCount = plg.Columns.Count
      .List = TbEntier
      For i = 1 To .ColumnCount
        cw = cw & plg.Columns(i).Width & ";"
        Next
      .ColumnWidths = cw
      .ListIndex = -1
    End With
     
    ComboBoxcon.Clear
    ComboBoxzon.Clear
    ComboBoxlig.Clear
     
    ComboBoxcon.AddItem "Conforme"
    ComboBoxcon.AddItem "Non-Conforme"
    ComboBoxcon.AddItem "En Attente"
     
    ComboBoxzon.AddItem "Conforme"
    ComboBoxzon.AddItem "Non-Conforme"
    ComboBoxzon.AddItem "Preparation"
    ComboBoxzon.AddItem "Controle"
    ComboBoxzon.AddItem "Recontrole"
     
    ComboBoxlig.AddItem "Ratio 1"
    ComboBoxlig.AddItem "Ratio 2"
    ComboBoxlig.AddItem "Ratio 3"
    ComboBoxlig.AddItem "Ratio 4"
    ComboBoxlig.AddItem "Ratio 5"
    ComboBoxlig.AddItem "Ratio 6"
    ComboBoxlig.AddItem "MLB"
    ComboBoxlig.AddItem "KALIX"
    ComboBoxlig.AddItem "Stoppil 3"
    ComboBoxlig.AddItem "Stoppil 4"
    ComboBoxlig.AddItem "Serac 2"
    ComboBoxlig.AddItem "Serac 3"
    ComboBoxlig.AddItem "Stoppil 2"
     
    End Sub
     
    Sub ListBox1_Click()
     
    Dim i As Integer
     
    i = ListBox1.ListIndex
    Row = ListBox1.ListIndex + 2
     
    TextBoxfor.Text = ListBox1.List(i, 0)
    TextBoxdes.Text = ListBox1.List(i, 1)
    ComboBoxcon.Text = ListBox1.List(i, 2)
    TextBoxlot.Text = ListBox1.List(i, 3)
    TextBoxqua.Text = ListBox1.List(i, 4)
    TextBoxfab.Text = CDate(ListBox1.List(i, 5))
    TextBoxfin.Text = CDate(ListBox1.List(i, 6))
    ComboBoxzon.Text = ListBox1.List(i, 7)
    TextBoxall.Text = ListBox1.List(i, 8)
    TextBoxcom.Text = ListBox1.List(i, 9)
     
    End Sub

  2. #2
    Expert confirmé
    Homme Profil pro
    aucune
    Inscrit en
    Septembre 2011
    Messages
    8 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Septembre 2011
    Messages : 8 208
    Par défaut
    Bonjour et bonne année à toi également,

    Bon d'habitude je n'ai pas beaucoup de chance car on ne repond pas beaucoup a mes questions, j'espere que celle ci sera la bonne
    On va tâcher de faire mentir les stats, mais tu n'y mets pas beaucoup du tien, non plus, avec ce que tu nous sors comme longueur de code

    Pourquoi est-ce que tu passes par un textbox pour alimenter la listbox ? Est-ce que tu entre les valeurs manuellement. D'où viennent les valeurs qui alimentent ce textbox ?

  3. #3
    Membre actif
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Décembre 2012
    Messages : 30
    Par défaut
    Merci beaucoup de prendre le temps de me repondre

    Alors je rentre des valeurs qui viennent d'un planning donc je rentre les references qui doivent sortir si elle s'affiche dans la listbox c'est que je les ai en stock ,voila pourquoi je voulais pour aller plus vite pouvoir marquer les references a la suite .cela dit ma recherche ne doit pas etre tres bonne car je n'arrive ni a supprimer ni a modifier mes lignes donc je pense que je devrais les revoir plus tard.

    Merci encore je peux envoyer mon dossier si c'est plus clair comme ca??

  4. #4
    Expert confirmé
    Homme Profil pro
    aucune
    Inscrit en
    Septembre 2011
    Messages
    8 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Septembre 2011
    Messages : 8 208
    Par défaut
    Alors je rentre des valeurs qui viennent d'un planning donc je rentre les references
    Est-ce qu'il s'agit de cellules d'une feuille et est-ce qu'il serait possible de se passer du textbox ?

  5. #5
    Membre actif
    Homme Profil pro
    Inscrit en
    Décembre 2012
    Messages
    30
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Décembre 2012
    Messages : 30
    Par défaut
    Et bien pour moi je pensais que la meilleur solution etait de pouvoir
    entrée la reference dans un textbox et qu'elle s'affiche dans une listbox car apres je les exportes sur une autre feuille pour pouvoir l'imprimer et sortir un planning juste .

    Maintenant est ce la meilleur facon je ne sais pas mais j'aimerai pourvoir aussi
    modifier ces lignes alors le textbox me parait tres bien , non ??

    j'envoi mon fichier pour que cela soit plus nette malgré surement toute les erreur de mes codes.
    Fichiers attachés Fichiers attachés

  6. #6
    Expert confirmé
    Homme Profil pro
    aucune
    Inscrit en
    Septembre 2011
    Messages
    8 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : aucune

    Informations forums :
    Inscription : Septembre 2011
    Messages : 8 208
    Par défaut
    Ou prends-tu les valeurs à chercher ? De fait, si tu déclenches la recherche avec la macro "TextBoxrec_Change", celle-ci se déclenche à chaque entrée de caractère. Est-ce ce que tu veux ?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2007] recherche multiple sur mon disque dur a partir d une colone
    Par redbull222 dans le forum Excel
    Réponses: 2
    Dernier message: 27/11/2011, 10h54
  2. [Toutes versions] Après une recherche multiple, regrouper les résultats
    Par Patak76 dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 14/11/2011, 09h18
  3. [AC-2003] Recherche multiple dans une zone de texte
    Par Orakle dans le forum IHM
    Réponses: 10
    Dernier message: 23/02/2010, 13h57
  4. Requête pour une recherche sur champs multiple d'une table
    Par fred777 dans le forum Requêtes et SQL.
    Réponses: 8
    Dernier message: 07/10/2008, 16h33
  5. Réponses: 4
    Dernier message: 01/02/2008, 21h12

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