Bonjour à tous,

J'ai un petit souci avec mes variables, au départ j'ai fait ma maccro sans pour tout ce qui concerne les cells(.,.) et ça marchait parfaitement mais ça faisait un peu "bordélique" pour continuer alors je les est nommé et remplacé tous les cells par les noms et là plus rien ne marche dans le select case, voici le code si quelqu'un à une explication :

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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
Sub test()
 
Application.EnableEvents = False
 
Dim x As String
 
x = Range("d3")
 
Cells(3, 11) = Cells(1, 23)
 
Dim date1 As Date
Dim broker As String
Dim pays As String      'code pays réglement/livraison
Dim sens As String
Dim choix_ttf As String ' O ou N
Dim choix_francosdg As String   'choix franco société de gestion
Dim quantite As Double
Dim cours As Double
Dim isin As Variant
Dim libelle As String
Dim devise As String
Dim courtage_broker As Double
Dim tva_ctgbroker As Double
Dim ttf As Double       'Montant d ela ttf
Dim sec_fee As Double
Dim comrl As Double     'commission de réglement/livraison
Dim tva_comrl As Double 'TVA/commisssion réglement/livraison
Dim courtage_sdg As Double
Dim tva_courtagesdg As Double   'TVA/courtage SDG
Dim flux_financier As Double
Dim quantitee_actualisee As Double
 
 
date1 = Cells(3, 1)
broker = Cells(3, 2)
pays = Cells(3, 3)
sens = Cells(3, 4)
choix_ttf = Cells(3, 5)
choix_francosdg = Cells(3, 6)
quantite = Cells(3, 7)
cours = Cells(3, 8)
isin = Cells(3, 9)
libelle = Cells(3, 10)
devise = Cells(3, 11)
courtage_broker = Cells(3, 13)
tva_ctgbroker = Cells(3, 14)
ttf = Cells(3, 15)
sec_fee = Cells(3, 16)
comrl = Cells(3, 17)
tva_comrl = Cells(3, 18)
courtage_sdg = Cells(3, 19)
tva_courtagesdg = Cells(3, 20)
flux_financier = Cells(3, 21)
quantitee_actualisee = Cells(3, 22)
 
 
Select Case x
 
    Case "A"
        'courtage broker (DEV)
 
 
 
 
                Sheets("BASE BROKERS").Activate
 
                    For i = 2 To Range("b:b").End(xlDown).Row
 
                        If Cells(i, 2).Value = broker Then
 
                            courtage = Cells(i, 3).Value
 
                        End If
 
                    Next i
 
                Sheets("HISTORIQUE NEGOCIATIONS").Activate
 
                    courtage_broker = quantite * cours * courtage
 
 
 
        'TTF
 
            If choix_ttf = "O" Then
                ttf = quantite * cours * 0.002
            Else: ttf = "0"
            End If
 
 
 
        'Com.de règl./livr.(EUR)
 
 
 
 
 
                Sheets("BASE REGLEMENT - LIVRAISON").Activate
 
                    For i = 2 To Range("b:b").End(xlDown).Row
 
                        If Cells(i, 2).Value = pays Then
 
                            Frais_de_reglement_livr = Cells(i, 3).Value
 
                        End If
 
                    Next i
 
                Sheets("HISTORIQUE NEGOCIATIONS").Activate
 
 
 
        'TVA/Com.règl./livr.
 
             Set sh13 = Worksheets("DONNEES DE BASE")
 
                    tva_comrl = comrl * sh13.Range("d2")
 
        'Courtage SDG
 
            If choix_francosdg = "N" Then
                If pays = "FR" Then
                    courtage_sdg = quantite * cours * sh13.Range("B11")
                        If courtage_sdg < sh13.Range("c11") Then
                             courtage_sdg = sh13.Range("c11")
 
                        End If
                End If
            End If
 
        'Flux financier
 
            flux_financier = -((quantite * cours) + courtage_broker + tva_ctgbroker + ttf + sec_fee + comrl + tva_comrl + courtage_sdg + tva_courtagesdg)
 
 
 
 
    Case "V"
 
      'courtage broker (DEV)
 
 
 
 
 
 
                Sheets("BASE BROKERS").Activate
 
                    For i = 2 To Range("b:b").End(xlDown).Row
 
                        If Cells(i, 2).Value = broker Then
 
                            courtage = Cells(i, 3).Value
 
                        End If
 
                    Next i
 
                Sheets("HISTORIQUE NEGOCIATIONS").Activate
 
                    courtage_broker = quantite * cours * courtage
 
 
 
 
        'Com.de règl./livr.(EUR)
 
 
 
 
 
                Sheets("BASE REGLEMENT - LIVRAISON").Activate
 
                    For i = 2 To Range("b:b").End(xlDown).Row
 
                        If Cells(i, 2).Value = pays Then
 
                            Frais_de_reglement_livr = Cells(i, 3).Value
 
                        End If
 
                    Next i
 
                Sheets("HISTORIQUE NEGOCIATIONS").Activate
 
 
 
        'TVA/Com.règl./livr.
 
             Set sh13 = Worksheets("DONNEES DE BASE")
 
                    tva_comrl = comrl * sh13.Range("d2")
 
        'Courtage SDG
 
            If choix_francosdg = "N" Then
                If pays = "FR" Then
                    courtage_sdg = quantite * cours * sh13.Range("B11")
                        If courtage_sdg < sh13.Range("c11") Then
                             courtage_sdg = sh13.Range("c11")
 
                        End If
                End If
            End If
 
        'Flux financier
 
            flux_financier = (quantite * cours) - courtage_broker - tva_ctgbroker - ttf - sec_fee - comrl - tva_comrl - courtage_sdg - tva_courtagesdg
 
 
 
    Case "ANUL"
 
        'courtage broker (DEV)
 
 
 
 
 
 
                Sheets("BASE BROKERS").Activate
 
                    For i = 2 To Range("b:b").End(xlDown).Row
 
                        If Cells(i, 2).Value = broker Then
 
                            courtage = Cells(i, 3).Value
 
                        End If
 
                    Next i
 
                Sheets("HISTORIQUE NEGOCIATIONS").Activate
 
                    Cells(3, 13) = -(Cells(3, 7) * Cells(3, 8) * courtage)
 
        'TTF
 
            If Cells(3, 5) = "O" Then
                Cells(3, 15) = -(Cells(3, 7) * Cells(3, 8) * 0.002)
            Else: Cells(3, 15) = "0"
            End If
 
 
 
        'Com.de règl./livr.(EUR)
 
 
 
 
 
                Sheets("BASE REGLEMENT - LIVRAISON").Activate
 
                    For i = 2 To Range("b:b").End(xlDown).Row
 
                        If Cells(i, 2).Value = pays Then
 
                            Frais_de_reglement_livr = Cells(i, 3).Value
 
                        End If
 
                    Next i
 
                Sheets("HISTORIQUE NEGOCIATIONS").Activate
 
                    Cells(3, 17) = -(Frais_de_reglement_livr)
 
        'TVA/Com.règl./livr.
 
             Set sh13 = Worksheets("DONNEES DE BASE")
 
                    Cells(3, 18) = Cells(3, 17) * sh13.Range("d2")
 
        'Courtage SDG
 
            If Cells(3, 6) = "N" Then
                If Cells(3, 3) = "FR" Then
                    Cells(3, 19) = -(Cells(3, 7) * Cells(3, 8) * sh13.Range("B11"))
                        If Cells(3, 19) > sh13.Range("c11") Then
                             Cells(3, 19) = -(sh13.Range("c11"))
 
                        End If
                End If
            End If
 
        'Flux financier
 
        Cells(3, 21) = (Cells(3, 7) * Cells(3, 8)) - Cells(3, 13) - Cells(3, 14) - Cells(3, 15) - Cells(3, 16) - Cells(3, 17) - Cells(3, 18) - Cells(3, 19) - Cells(3, 20)
 
End Select
 
End Sub