Salut,
en essayant d'optimiser mon code, j'ai un blocage.
Dans une feuille j'ai une listbox pour choisir des langues. Ce choix à un impact sur les différentes feuilles du classeur et les userform. Le code que j'ai appelé Langue est dans le module. J'ai défini dans un tableau à 3 colonnes le vocabulaire dans les trois langues. J'avais 3 procédures if (avec if la valeur de mon listbox= français, if la valeur= anglais,...);
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'Partie principale de langage ()
If Feuil1.Langage.Value = "Français" Then
        Feuil1.Cells(2, 1) = Montableau(1, 1)
        Feuil1.Cells(5, 1) = Montableau(2, 1)
        Feuil1.Cells(6, 1) = Montableau(3, 1)
        Feuil1.Cells(7, 1) = Montableau(4, 1)
        Feuil1.Cells(8, 1) = Montableau(5, 1)
        Feuil1.Cells(9, 1) = Montableau(6, 1)
        Feuil1.Cells(11, 1) = Montableau(7, 1)
        Feuil1.Cells(12, 1) = Montableau(8, 1)
        Feuil1.Cells(13, 1) = Montableau(9, 1)
        Feuil1.Cells(14, 1) = Montableau(10, 1)
        Feuil1.Cells(15, 1) = Montableau(11, 1)
        Feuil1.Cells(16, 1) = Montableau(12, 1)
        Feuil1.Cells(18, 1) = Montableau(13, 1)
        Feuil1.Cells(19, 1) = Montableau(14, 1)
        Feuil1.Cells(20, 1) = Montableau(15, 1)
        Feuil1.Cells(21, 1) = Montableau(16, 1)
        Feuil1.Cells(22, 1) = Montableau(17, 1)
        Feuil1.Cells(24, 1) = Montableau(18, 1)
        Feuil1.Cells(25, 1) = Montableau(19, 1)
        Feuil1.Cells(26, 1) = Montableau(20, 1)
        Feuil1.Cells(28, 1) = Montableau(21, 1)
        Feuil1.Cells(29, 1) = Montableau(22, 1)
        Feuil1.Cells(30, 1) = Montableau(23, 1)
        Feuil1.Cells(31, 1) = Montableau(24, 1)
ElseIf Feuil1.Langage.Value = "English" Then
        Feuil1.Cells(2, 1) = Montableau(1, 2)
        Feuil1.Cells(5, 1) = Montableau(2, 2)
        Feuil1.Cells(6, 1) = Montableau(3, 2)
        Feuil1.Cells(7, 1) = Montableau(4, 2)
        Feuil1.Cells(8, 1) = Montableau(5, 2)
        Feuil1.Cells(9, 1) = Montableau(6, 2)
        Feuil1.Cells(11, 1) = Montableau(7, 2)
        Feuil1.Cells(12, 1) = Montableau(8, 2)
        Feuil1.Cells(13, 1) = Montableau(9, 2)
        Feuil1.Cells(14, 1) = Montableau(10, 2)
        Feuil1.Cells(15, 1) = Montableau(11, 2)
        Feuil1.Cells(16, 1) = Montableau(12, 2)
        Feuil1.Cells(18, 1) = Montableau(13, 2)
        Feuil1.Cells(19, 1) = Montableau(14, 2)
        Feuil1.Cells(20, 1) = Montableau(15, 2)
        Feuil1.Cells(21, 1) = Montableau(16, 2)
        Feuil1.Cells(22, 1) = Montableau(17, 2)
        Feuil1.Cells(24, 1) = Montableau(18, 2)
        Feuil1.Cells(25, 1) = Montableau(19, 2)
        Feuil1.Cells(26, 1) = Montableau(20, 2)
        Feuil1.Cells(28, 1) = Montableau(21, 1)
        Feuil1.Cells(29, 1) = Montableau(22, 1)
        Feuil1.Cells(30, 1) = Montableau(23, 1)
        Feuil1.Cells(31, 1) = Montableau(24, 1)
       ElseIf Feuil1.Langage.Value = "Deutsch" Then
        Feuil1.Cells(2, 1) = Montableau(1, 3)
        Feuil1.Cells(5, 1) = Montableau(2, 3)
        Feuil1.Cells(6, 1) = Montableau(3, 3)
        Feuil1.Cells(7, 1) = Montableau(4, 3)
        Feuil1.Cells(8, 1) = Montableau(5, 3)
        Feuil1.Cells(9, 1) = Montableau(6, 3)
        Feuil1.Cells(11, 1) = Montableau(7, 3)
        Feuil1.Cells(12, 1) = Montableau(8, 3)
        Feuil1.Cells(13, 1) = Montableau(9, 3)
        Feuil1.Cells(14, 1) = Montableau(10, 3)
        Feuil1.Cells(15, 1) = Montableau(11, 3)
        Feuil1.Cells(16, 1) = Montableau(12, 3)
        Feuil1.Cells(18, 1) = Montableau(13, 3)
        Feuil1.Cells(19, 1) = Montableau(14, 3)
        Feuil1.Cells(20, 1) = Montableau(15, 3)
        Feuil1.Cells(21, 1) = Montableau(16, 3)
        Feuil1.Cells(22, 1) = Montableau(17, 3)
        Feuil1.Cells(24, 1) = Montableau(18, 3)
        Feuil1.Cells(25, 1) = Montableau(19, 3)
        Feuil1.Cells(26, 1) = Montableau(20, 3)
        Feuil1.Cells(28, 1) = Montableau(21, 1)
        Feuil1.Cells(29, 1) = Montableau(22, 1)
        Feuil1.Cells(30, 1) = Montableau(23, 1)
        Feuil1.Cells(31, 1) = Montableau(24, 1)
je me suis dit que pour raccourcir j'allais utiliser les index de la listbox:
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
'partie principale de langage ()
Feuil1.Cells(2, 1) = Montableau(1, l)
        Feuil1.Cells(5, 1) = Montableau(2, l)
        Feuil1.Cells(6, 1) = Montableau(3, l)
        Feuil1.Cells(7, 1) = Montableau(4, l)
        Feuil1.Cells(8, 1) = Montableau(5, l)
        Feuil1.Cells(9, 1) = Montableau(6, l)
        Feuil1.Cells(11, 1) = Montableau(7, l)
        Feuil1.Cells(12, 1) = Montableau(8, l)
        Feuil1.Cells(13, 1) = Montableau(9, l)
        Feuil1.Cells(14, 1) = Montableau(10, l)
        Feuil1.Cells(15, 1) = Montableau(11, l)
        Feuil1.Cells(16, 1) = Montableau(12, l)
        Feuil1.Cells(18, 1) = Montableau(13, l)
        Feuil1.Cells(19, 1) = Montableau(14, l)
        Feuil1.Cells(20, 1) = Montableau(15, l)
        Feuil1.Cells(21, 1) = Montableau(16, l)
        Feuil1.Cells(22, 1) = Montableau(17, l)
        Feuil1.Cells(24, 1) = Montableau(18, l)
        Feuil1.Cells(25, 1) = Montableau(19, l)
        Feuil1.Cells(26, 1) = Montableau(20, l)
        Feuil1.Cells(28, 1) = Montableau(21, l)
        Feuil1.Cells(29, 1) = Montableau(22, l)
        Feuil1.Cells(30, 1) = Montableau(23, l)
        Feuil1.Cells(31, 1) = Montableau(24, l)
ça divise par trois la taille de mon code, dans feuil2, j'ai le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
Private Sub Langage_Click()
l=langage.ListIndex+1
MsgBox l
Langue
End Sub