Bonjour,
Je n'ai pas eu le temps de répondre. Le boulot, les études ...
Ceci dit, j'ai regarder la syntaxe du code et je n'y trouve que 2 choses bizarres !
1) Les variables [ i ] et [ j ] ne sont pas déclarés.
2) Dans l'instruction [ Cells(L, C).Select ], les lettres [ L ] et [ C ] ne sont pas déclaré.
Si tu veux tout sélectionner, l'instruction [ Cells.Select ] est suffisante.
Voici ce que ça donne :
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
Dim i As Long, j As Long
'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
Cells.Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(Model,Tableau!R6C1:R213C13, 6, 'False')"
End If
Next i
Compteur = Compteur - 1
Compteur2 = Compteur2 - 1
Next j
End Sub
'
Je ne travaille que très peu avec l'instruction [ ElseIf ], mais je crois que tu dois valider
cette structure de contrôle, tu pourrais essayer comme ceci :
If Cells(4, j) Is Empty Then
Cells(i, j).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(Model, BodyType, Marque, Temps)"
Else
If Cells(4, j) Is Not Empty Then
'Cells(L, C).Select
Cells.Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(Model,Tableau!R6C1:R213C13, 6, 'False')"
End If
End If
'
Et le second If imbriqué est implicite :
If Cells(4, j) Is Empty Then
Cells(i, j).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(Model, BodyType, Marque, Temps)"
Else
'Cells(L, C).Select
Cells.Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(Model,Tableau!R6C1:R213C13, 6, 'False')"
End If
'
Lupin