Option Explicit
Private WithEvents CLs As ComboBoxLiées, CAs As ControlsAssociés, TLgn() As Long, LCou As Long, TVL()
Private Sub UserForm_Initialize() ' initialisation du formulaire
Set CLs = New ComboBoxLiées: CLs.Plage Feuil2
Set CAs = New ControlsAssociés: Set CAs.Colonnes = CLs.Colonnes
CLs.Add Me.CBxNom, "NOM"
CLs.Add Me.CBxRef, "REFERENCE"
CLs.Add Me.CBxMarque, "MARQUE"
CLs.Add Me.CBxCatég, "CATEGORIE"
CAs.Add Me.TBxPrixA, "PRIX ACHAT"
CAs.Add Me.TBxCoef, "COEF"
CAs.Add Me.TBxPrixV, "PRIX DE VENTE"
CAs.Add Me.TBxMarge, "MARGE"
CAs.Add Me.TBxDtPxA, "DATE PRIX ACHAT"
CAs.Add Me.TBxFourn, "FOURNISSEUR"
CAs.Add Me.TBxNotes, "NOTES"
CLs.CouleurSympa
CLs.Actualiser
End Sub
Function reset_all_controls() ' ???
CLs.Nettoyer
End Function
Private Sub CLs_Change(ByVal Complet As Boolean, ByVal NbrLgn As Long)
ListBox1.Clear
ReDim TVL(1 To 1, 1 To CLs.Colonnes.Count)
CAs.ValeursDepuis TVL
LCou = 0
End Sub
Private Sub CLs_Résultat(Lignes() As Long)
Dim TDon(), LDon As Long, TLBx(), LLbx As Long, C As Integer
TLgn = Lignes
If UBound(TLgn) = 1 Then
LCou = Lignes(1)
TVL = CLs.Lignes(LCou).Range.Value
CAs.ValeursDepuis TVL
Else
TDon = CLs.PlgTablo
ReDim TLBx(1 To UBound(TLgn), 1 To CLs.Colonnes.Count)
For LLbx = 1 To UBound(TLBx, 1): LDon = TLgn(LLbx)
For C = 1 To UBound(TLBx, 2): TLBx(LLbx, C) = TDon(LDon, C)
Next C, LLbx
ListBox1.List = TLBx
End If
End Sub