Salut Bibu
Merci de ta réponse, il est vrai que je n'avais pas pensais à faire un set avec la déclaration Range, sauf que maintenant mon soucis (je suis embêtant) c'est que je ne sais pas utiliser cela pour remplir ma ListBox1
'On met en place les variables
Option Explicit
Dim Page As Variant
Dim Fdnait As Worksheet, Fdi As Worksheet
Dim tbb As String
Private Sub UserForm_Initialize()
Dim P As Workbook
Dim Fb, Fs As Worksheet
Dim tbb As Range
Set P = ThisWorkbook
P.Activate
Me.OptionButton1.Value = True
Set Fb = Sheets("DI")
Set Fs = Sheets("DNAIT")
Set tbb = Fb.Range("A2:J" & Fb.Range("A" & Rows.Count).End(xlUp).Row)
'Paramètrage de la ListBox
Me.ListBox1.ColumnCount = 7 'Nombre de colonne
Me.ListBox1.ColumnWidths = "150; 100; 300; 300; 450; 50; 150" 'La taille de la colonne 1,2 et 3
End Sub
Private Sub CommandButton1_Click()
Me.Hide
End Sub
Private Sub OptionButton1_Click()
Page = "DI"
'AlimenteList
End Sub
Private Sub OptionButton2_Click()
Page = "DNAIT"
'AlimenteList
End Sub
Private Sub AlimenteList()
Dim mondico As Object, i As Integer, Tdi As String
Me.ListBox1.Clear
If Page = "DI" Then
For i = LBound(tbb) To UBound(tbb)
Me.ListBox1.AddItem tbb(i, 1)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Left(tbb(i, 2), 10)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = tbb(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = tbb(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = tbb(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = tbb(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = tbb(i, 7)
End If
If Page = "DNAIT" Then
End If
End Sub
Si t'as une idée je veux bien la connaitre
Merci d'avance