Private Sub UserForm_Initialize()
Usf_VisibleAchats = True
Application.ScreenUpdating = False
Me.Left = Application.Left + Application.Width / 2 - Me.Width / 2
Me.Top = Application.Top + Application.Height / 2 - Me.Height / 2
Set f = Sheets("TbAchats")
Set rng = f.Range("A2:F" & f.[a1000000].End(xlUp).Row) ' BD (1 colonne de plus)
colInterro = Array(1, 2, 3, 4, 5, 6) ' colonnes à interroger (adapter)
colVisu = Array(1, 2, 3, 4, 5, 6) ' colonnes à visualiser (adapter)
Decal = rng.Row - 1 ' début de la BD
BD = rng.Value
col = UBound(BD, 2): For i = LBound(BD) To UBound(BD): BD(i, col) = i + Decal: Next i 'no enreg
NcolInt = UBound(colInterro) + 1
Ncol = UBound(colVisu) + 1 ' : ReDim ancien(1 To 1, 1 To Ncol)
Me.LstCharges.ColumnCount = UBound(colVisu) + 2
Me.LstCharges.ColumnWidths = "60;200;200;50;0;0;0"
'-- génération de choix()
ReDim choix(1 To UBound(BD))
col = UBound(BD, 2)
For i = LBound(BD) To UBound(BD)
For Each k In colInterro
choix(i) = choix(i) & BD(i, k) & "|"
If IsDate(BD(i, k)) Then BD(i, k) = Format(BD(i, k), "dd/mm/yyyy")
BD(i, 1) = CDate(BD(i, 1))
Next k
choix(i) = choix(i) & BD(i, col) & "|" ' no enreg
Next i
'--- valeurs initiales dans ListBox
Dim Tbl(): ReDim Tbl(1 To UBound(BD), 1 To Ncol + 1)
For i = 1 To UBound(BD)
C = 0
For Each k In colVisu
C = C + 1: Tbl(i, C) = BD(i, k)
Next k
C = C + 1: Tbl(i, C) = i + Decal
Next i
Me.LstCharges.List = Tbl
Me.LstCharges.ListIndex = -1
Application.ScreenUpdating = True
RemplitlesListes
BtnModifier.Visible = False
End Sub