ERREUR "référence de variable de contrôle...)
Bonjour, j'ai écrit une petite macro assez simple et j'ai le message d'erreur suivant " référence de variable de contrôle incorrect dans Next" ! Est ce quelqu'un voit d'où cela peut venir ? Merci d'avance pour votre aide.
Sub PlanningMarque()
Dim Marque As String
Dim Compteur As Double
Dim Compteur2 As Double
Dim Model As String
Dim Segment As String
Dim BodyType As String
Dim Temps As String
'Initiatlisation des variables
Compteur = -3 'colonne Concatener
Compteur2 = -2 'colonne Transfert
Compteur3 = -5
Compteur4 = -4
For i = 5 To 40 'i = Lignes
For j = 6 To 31 'j = Colonnes
' traitement des variables
Marque = Cells(2, j).Value
Temps = Cells(1, j).Value
Segment = Cells(i, 1).Value
BodyType = Cells(i, 2).Value
Cells(i, j).Offset(i, Compteur).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(Segment, BodyType, Marque, Temps)"
Cells(i, j).Offset(i, Compteur2).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Tableau!R6C1:R213C13, 6, 'False')"
Model = Cells(i, 4).Value
Cells(i, j).Select
If Cells(4, j) Is Empty Then
Cells(i, j).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(Model, BodyType, Marque, Temps)"
ElseIf Cells(4, j) Is Not Empty Then
Cells(L, C).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(Model,Tableau!R6C1:R213C13, 6, 'False')"
End If
Next i
Compteur = Compteur - 1
Compteur2 = Compteur2 - 1
Next j
End Sub
Sub PlanningMarque()
Dim Marque As String
Dim Compteur As Double
Dim Compteur2 As Double
Dim Model As String
Dim Segment As String
Dim BodyType As String
Dim Temps As String
'Initiatlisation des variables
Compteur = -3 'colonne Concatener
Compteur2 = -2 'colonne Transfert
Compteur3 = -5
Compteur4 = -4
For i = 5 To 40 'i = Lignes
For j = 6 To 31 'j = Colonnes
' traitement des variables
Marque = Cells(2, j).Value
Temps = Cells(1, j).Value
Segment = Cells(i, 1).Value
BodyType = Cells(i, 2).Value
Cells(i, j).Offset(i, Compteur).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(Segment, BodyType, Marque, Temps)"
Cells(i, j).Offset(i, Compteur2).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],Tableau!R6C1:R213C13, 6, 'False')"
Model = Cells(i, 4).Value
Cells(i, j).Select
If Cells(4, j) Is Empty Then
Cells(i, j).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(Model, BodyType, Marque, Temps)"
ElseIf Cells(4, j) Is Not Empty Then
Cells(L, C).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(Model,Tableau!R6C1:R213C13, 6, 'False')"
End If
Next i
Compteur = Compteur - 1
Compteur2 = Compteur2 - 1
Next j
End Sub
Configuration: Windows XP Firefox 3.0.4