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