Bonjour,
J'ai commencé à faire un nouvel userform
Ce que je souhaite faire :
Lorsque je clique sur le bouton "plan classe 6" une listbox parait qui correspond à B4 : D300
Et j'aimerais que lorsque je clic sur une case à cocher il y a un "X" qui se met dans la colonne D en fonction du code choisi.
A l'heure actuelle mon code fonctionne, mais lorsque je ré-ouvre l'userform les croix s'efface
Comment faire pour conserve les "X" dans la colonne D.
Merci de votre aide.
Ci-joint le code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 Private Sub UserForm_Initialize() ListBox1.Clear End Sub Public Sub CommandButton_classe_6_Click() ListBox1.ColumnCount = 3 ListBox1.ColumnWidths = "30;250;50" ListBox1.List = Sheets("Plan_compta").Range("B4:D300").Value End Sub Private Sub ListBox1_Change() Dim c Dim val As String Dim i As Long 'boucle mise a X For i = ListBox1.ListCount - 1 To 0 Step -1 If ListBox1.Selected(i) Then val = ListBox1.List(i) For Each c In Sheets("Plan_compta").Range("B4:B300") If c <> "" Then If c = val Then c.Offset(0, 2) = "X" End If End If Next End If Next 'boucle suppression X For i = ListBox1.ListCount - 1 To 0 Step -1 If ListBox1.Selected(i) Then Else val = ListBox1.List(i) For Each c In Sheets("Plan_compta").Range("B4:B300") If c <> "" Then If c = val Then c.Offset(0, 2) = "" End If End If Next End If Next End Sub
Partager