Affichage sur listbox en fonction du critère combobox

Bonjour tout le monde

svp j'ai besoin de votre aide. sur mon userform je souhaite afficher sur la listbox tous les contrats qui n'ont pas été saisis par la personne de la combobox1

pour le bouton valider il doit me renvoyer le nom de la valeur de la combobox1(responsable de validation) sur la colonne 5 et la date de validation sur la colonne 6 des contrats qui ont été affichés sur la listbox

je souhaite afficher les entête de la listbox

pour plus d'éclaircissements ci-joint mon fichier

Merci pour vos suggestions

Bonjour,

à tester,

Private Sub ComboBox1_Change()
Dim liste As Variant, i As Long, j As Integer, n As Integer, cl As Variant, frm As Variant
Dim LB2(), NoPol As String, rw As Long, tt As String
rw = Sheets("Feuil1").Cells(Rows.Count, 1).End(xlUp).Row

NoPol = Me.ComboBox1.List(Me.ComboBox1.ListIndex)
cl = Array(1, 2, 3, 4, 5, 6, 7)
liste = Sheets("Feuil1").Range("A1:G" & rw).Value

For i = LBound(liste) To UBound(liste)
    If i <> 1 And liste(i, 5) <> NoPol Then
        Sheets("Feuil1").Cells(i, "F") = Me.ComboBox1
        Sheets("Feuil1").Cells(i, "G") = Date
    End If

    If i = 1 Or liste(i, 5) <> NoPol Then
        n = n + 1
        For j = LBound(cl) To UBound(cl)
          ReDim Preserve LB2(UBound(cl), n)
          LB2(j, n - 1) = liste(i, cl(j)) 'Format(liste(i, cl(j)), frm(j))
        Next j
    End If
Next i
Me.ListBox1.List = Application.Transpose(LB2)
End Sub

Private Sub UserForm_Initialize()
Me.ListBox1.ColumnCount = 7
TextBox1.Value = Format(Now(), "dd/mm/yyyy")
ComboBox1.List = Feuil2.Range("A2:A" & Feuil2.Range("A" & Rows.Count).End(xlUp).Row).Value 'responsable_saisie
End Sub

Bonjour,

cf PJ

Boisgontier

Rechercher des sujets similaires à "affichage listbox fonction critere combobox"