Dim n As Byte, k As Byte, x As Byte, lig As Long, L As Long
Private Sub ComboBox1_Change()
If ComboBox1 <> "" Then ListBox1.Clear
End Sub
Private Sub CommandButton1_Click()
Dim R As Range, ColDate
If ComboBox1 <> "" Then
For Each R In [Tb]
If R Like ComboBox1 & "*" And R.Row <> L Then
L = R.Row - 1
ListBox1.AddItem [Tb].Item(L, 1)
For k = 2 To n
ListBox1.List(ListBox1.ListCount - 1, k - 1) = [Tb].Item(L, k)
ColDate = ListBox1.List(ListBox1.ListCount - 1, k - 1)
ListBox1.List(ListBox1.ListCount - 1, k - 1) = Format(ColDate, "dd.mm.yyyy")
Next
End If
Next
Else
ListBox1.Clear
End If
End Sub
Private Sub UserForm_Activate()
ComboBox1 = ""
ListBox1.Clear
End Sub
Private Sub UserForm_Initialize()
Dim ColDate
n = [Tb].Columns.Count
ListBox1.ColumnCount = [Tb].Columns.Count
ListBox1.ColumnWidths = "50;90;80;70;70;70;60"
For k = 1 To n
Me("Label" & k) = [Tb].Item(0, k)
Me("Label" & k).Top = Me("Label" & k).Top + 5
Next
ListBox1.Clear
With Sheets("Factures")
lig = .Range("a65536").End(xlUp).Row
For i = 2 To .Range("b65536").End(xlUp).Row
ComboBox1 = .Range("b" & i)
If ComboBox1.ListIndex = -1 Then ComboBox1.AddItem .Range("b" & i)
Next i
For x = 2 To lig
ListBox1.AddItem .Range("a" & x)
For j = 2 To 7
ListBox1.List(ListBox1.ListCount - 1, j - 1) = .Cells(x, j)
ColDate = ListBox1.List(ListBox1.ListCount - 1, j - 1)
If IsDate(ColDate) Then _
ListBox1.List(ListBox1.ListCount - 1, j - 1) = Format(ColDate, "dd.mm.yyyy")
Next j
Next x
End With
End Sub