Microsoft 365 Réinitialiser concombox et probleme modification bd

largo41

XLDnaute Nouveau
Bonjour à tous

quand je lance userform que je clique sur la combobox1 Me trouve bien la liste des clients sans doublon ça alimente bien la 2e combobox en me mettant les bon N°facture du client

Le problème c'est que si je re sélectionne un autre client dans la combobox1 dans la 2 il y a toutes les factures qui apparaissent je suis donc obligé de refermer userform Et de le relancer



2e problème c'est quand je remplis la combobox3 et la textbos5 Et que je valide ça ne modifie pas la facture existante Ça me rajoute une ligne supplémentaire

Merci d'avance pour votre aide
VB:
Option Explicit

Dim fbd, derLn, ln, dico1, dico2

Private Sub ComboBox1_Change()
    ComboBox2.Clear
    TextBox1 = ""
    TextBox2 = ""
    TextBox3 = ""
     TextBox4 = ""
    For ln = 2 To fbd.Range("A" & derLn).Row
        If fbd.Range("C" & ln) = ComboBox1 Then
            dico2(fbd.Range("A" & ln).Value) = ""
        End If
    Next ln
    ComboBox2.List = Application.Transpose(dico2.keys)
End Sub

Private Sub ComboBox2_Change()

    TextBox1 = ""
    TextBox2 = ""
    TextBox3 = ""
    TextBox4 = ""
    For ln = 2 To fbd.Range("A" & derLn).Row
        If fbd.Range("C" & ln) = ComboBox1 And fbd.Range("A" & ln) = ComboBox2 Then
            TextBox1 = fbd.Range("K" & ln)
            TextBox2 = fbd.Range("BN" & ln)
            TextBox3 = fbd.Range("CP" & ln)
            TextBox4 = fbd.Range("N" & ln)
        End If
    Next ln

End Sub



Private Sub CommandButton1_Click()
    fbd.Range("N" & ln) = ComboBox3
    fbd.Range("CP" & ln) = TextBox5
    Unload Me
End Sub

Private Sub CommandButton2_Click()
FormCal.Show
End Sub

Private Sub UserForm_Initialize()
 
    Set fbd = Sheets("Base facturation")
    Set dico1 = CreateObject("Scripting.Dictionary")
    Set dico2 = CreateObject("Scripting.Dictionary")
    derLn = fbd.Range("C" & Rows.Count).End(xlUp).Row
    For ln = 2 To derLn
        dico1(fbd.Range("C" & ln).Value) = ""
    Next ln
    ComboBox1.List = Application.Transpose(dico1.keys)
    ComboBox3.ColumnCount = 1
 ComboBox3.List() = Array("", "Réglé", "Non Réglé")
End Sub
 
Dernière édition:

Discussions similaires

Réponses
6
Affichages
202

Statistiques des forums

Discussions
311 720
Messages
2 081 909
Membres
101 836
dernier inscrit
karmon