Bonjour,
Je cherche à déclarer mes variables afin quelles gardent leurs valeurs après le passage de la ligne 26 à la ligne27
quelqu'un pourrait-il m'expliquer ce que je fais mal:
voici une partie du code
Ligne26:
col = col + 1
If Range("H" & col) = 0 Then Ddr: Exit Sub
For ar = a + c + e + g + k + m + o + q + s + u + w + y + ac + ae + ag + ai + ak + am + ao + aq + 1 To 54
at = at + 1 'compte tour
reliquat20 = restafab20
Cells(col, 10 + a + c + e + g + k + m + o + q + s + u + w + y + ac + ae + ag + ai + ak + am + ao + aq) = reliquat20
nombpièces = (Cells(5, 10 + ar) + Cells(col, 9 + ar))
restafab21 = nombpièces - Range("H" & col)
If restafab21 > 0 Then nombpièces = Range("H" & col)
If reliquat20 >Range("H" & col) Then ar ar - 1
If reliquat20 >Range("H" & col) Then at at - 1
If reliquat20 >Range("H" & col) Then restafab21 reliquat20 - nombpièces
Cells(col, 10 + ar) = nombpièces
If nombpièces = Range("H" & col) Then Trideslignes2: Exit Sub
Next ar
End Sub
-----------------------------------------------------------------------------------
Public Sub Trideslignes2()
Ligne27:
col = 26
col = col + 1
If Range("H" & col) = 0 Then Ddr: Exit Sub
For au = a + c + e + g + k + m + o + q + s + u + w + y + ac + ae + ag + ai + ak + am + ao + aq + at + 1 To 54
av = av + 1 'compte tour
reliquat21 = restafab21
Cells(col, 10 + a + c + e + g + k + m + o + q + s + u + w + y + ac + ae + ag + ai + ak + am + ao + aq + at) = reliquat21
nombpièces = (Cells(5, 10 + au) + Cells(col, 9 + au))
restafab22 = nombpièces - Range("H" & col)
If restafab22 > 0 Then nombpièces = Range("H" & col)
If reliquat21 >Range("H" & col) Then au au - 1
If reliquat21 >Range("H" & col) Then av av - 1
If reliquat21 >Range("H" & col) Then restafab22 reliquat21 - nombpièces
Cells(col, 10 + au) = nombpièces
If nombpièces = Range("H" & col) Then GoTo Ligne28
Next au
cs_Jack
Messages postés14006Date d'inscriptionsamedi 29 décembre 2001StatutModérateurDernière intervention28 août 201579 7 août 2012 à 22:12
Salut
Confu tout ça.
La prochaine fois, utilise la coloration syntaxique (3ème icone à droite) = Plus facile à lire et conserve l'indentation des lignes (espaces en tête de ligne)
- Si tes variables sont utilisées dans plusieurs Sub ou Function d'une même page de code :
Déclare ta variable en Private dans la partie "déclarations", en tête de cette même page de code.
- Si les Sub ou Function se trouvent sur des pages de code différentes, il te faut créer un module, puis déclarer tes variables en Public dans sa partie "déclarations".
Dans tous les cas, il faut les dimensionner.
Vala
Jack, MVP VB NB : Je ne répondrai pas aux messages privés
Le savoir est la seule matière qui s'accroit quand on la partage (Socrate)