combobox et listbox avec variable

chris541

XLDnaute Junior
Bonjour à toutes et à tous
j'ai préparé un userform et je souhaite récupérer les items correspondants au choix de la combobox1
tout est prêt dans le fichier joint
Merci pour votre aide
:rolleyes:
 

Pièces jointes

  • TEST.xlsm
    21.2 KB · Affichages: 52
  • TEST.xlsm
    21.2 KB · Affichages: 71
  • TEST.xlsm
    21.2 KB · Affichages: 58

chris541

XLDnaute Junior
Re : combobox et listbox avec variable

Comment faire pour reporter la date ( ligne2) dans la tex box de l'userform et ce pour chaque changement de colonne..
merci
 

Pièces jointes

  • TEST.xlsm
    22.4 KB · Affichages: 35
  • TEST.xlsm
    22.4 KB · Affichages: 37
  • TEST.xlsm
    22.4 KB · Affichages: 41

chris541

XLDnaute Junior
Re : combobox et listbox avec variable

Super c exactement ce qu'il me fallait,
merci
sans abuser de ton savoir faire je souhaite terminer cet userform en faisant une recherche par mois
dans le fichier ci joint ...en te remerciant bcp
chris
 

Pièces jointes

  • TEST.xlsm
    22.8 KB · Affichages: 39
  • TEST.xlsm
    22.8 KB · Affichages: 40
  • TEST.xlsm
    22.8 KB · Affichages: 41

Pierrot93

XLDnaute Barbatruc
Re : combobox et listbox avec variable

Re,

essaye ceci :
Code:
Option Explicit
 Private Sub UserForm_Initialize()
 Dim i As Long
 For i = 2 To Range("IV2").End(xlToLeft).Column Step 2
    ComboBox2.AddItem Cells(2, i).Text
 Next i
 ComboBox1.List = Range("A1:A" & Range("A65536").End(xlUp).Row).Value
 TextBox1 = Cells(2, ActiveCell.Column).Text
 End Sub
 Private Sub ComboBox2_Click()
 Dim i As Integer, m As Byte
 If ComboBox1.ListIndex = -1 Or ComboBox2.ListIndex = -1 Then Exit Sub
 m = ComboBox2.ListIndex + 2
 For i = 4 To 8
     If Cells(i, m).Text Like "*" & ComboBox1.Value & "*" Then _
         ListBox1.AddItem Cells(i, m).Text & " " & Cells(i, m).Offset(0, 1)
 Next i
 End Sub
 

chris541

XLDnaute Junior
Re : combobox et listbox avec variable

super! merci , j'ai testé :
je dois faire le choix en combobox1.... , est il possible d'inverser? c a dire de sélectionner le mois en combobox2 puis après faire le tri à partir de la combobox1?
merci d'avance
chris
 

Pierrot93

XLDnaute Barbatruc
Re : combobox et listbox avec variable

Re,

Merci! mais en testant le fichier je n'ai qu'un mois sur 2 (ex :CB ca fonctionne en octobre mais plus en nov ...)

modifie comme suit :
Code:
Option Explicit
 Private Sub UserForm_Initialize()
 Dim i As Long
 For i = 2 To Range("IV2").End(xlToLeft).Column Step 2
    ComboBox2.AddItem Cells(2, i).Text
 Next i
 ComboBox1.List = Range("A1:A" & Range("A65536").End(xlUp).Row).Value
 TextBox1 = Cells(2, ActiveCell.Column).Text
 End Sub
 Private Sub ComboBox2_Click()
 Dim i As Integer, m As Byte
 If ComboBox1.ListIndex = -1 Or ComboBox2.ListIndex = -1 Then Exit Sub
 m = ComboBox2.ListIndex * 2 + 2
 ListBox1.Clear
 For i = 4 To 8
     If Cells(i, m).Text Like "*" & ComboBox1.Value & "*" Then _
         ListBox1.AddItem Cells(i, m).Text & " " & Cells(i, m).Offset(0, 1)
 Next i
 End Sub
 

chris541

XLDnaute Junior
Re : combobox et listbox avec variable

juste une petite question:
Est il possible de calculer la somme du tri (obtenue partir du résultat en listbox1 )?
j'ai préparé un textbox pour afficher la somme obtenue...
Merci bcp
 

Pièces jointes

  • TEST.xlsm
    22.5 KB · Affichages: 34
  • TEST.xlsm
    22.5 KB · Affichages: 37
  • TEST.xlsm
    22.5 KB · Affichages: 37

Statistiques des forums

Discussions
312 770
Messages
2 091 944
Membres
105 118
dernier inscrit
XDL84