Private Sub Worksheet_Change(ByVal Target As Range)
l = ActiveCell.Row
r = ActiveCell.Column
If l = 6 Or l = 33 Or l = 60 Or l = 87 Or l = 114 Or l = 141 Then GoTo matin Else
If l = 12 Or l = 39 Or l = 66 Or l = 93 Or l = 120 Or l = 147 Then GoTo apres_midi Else
If l = 18 Or l = 45 Or l = 72 Or l = 99 Or l = 126 Or l = 153 Then GoTo extra Else
Exit Sub
matin:
If Not ActiveSheet.Cells(l + 1, r).HasFormula And Len(ActiveCell) = 0 Then
ActiveSheet.Cells(l + 1, r).FormulaR1C1 = "=IF(R[-1]C="""","""",VLOOKUP(R[-1]C,Etablissements!R1:R1048576,2))"
Else
If Not ActiveSheet.Cells(l + 1, r + 3).HasFormula And Len(ActiveCell) = 0 Then
ActiveSheet.Cells(l + 1, r + 3).Activate
ActiveSheet.Cells(l + 1, r + 3).FormulaR1C1 = "=IF(R[-1]C[-3]="""","""",VLOOKUP(R[-1]C[-3],Etablissements!R1:R1048576,3))"
Else
End If
Exit Sub
apres_midi:
If Not ActiveSheet.Cells(l + 1, r).HasFormula And Len(ActiveCell) = 0 Then
ActiveSheet.Cells(l + 1, r).FormulaR1C1 = "=IF(R[-1]C="""","""",VLOOKUP(R[-1]C,Etablissements!R1:R1048576,4))"
Else
If Not ActiveSheet.Cells(l + 1, r + 3).HasFormula And Len(ActiveCell) = 0 Then
ActiveSheet.Cells(l + 1, r + 3).Activate
ActiveSheet.Cells(l + 1, r + 3).FormulaR1C1 = "=IF(R[-1]C[-3]="""","""",VLOOKUP(R[-1]C[-3],Etablissements!R1:R1048576,5))"
Else
End If
Exit Sub
extra:
If Not ActiveSheet.Cells(l + 1, r).HasFormula And Len(ActiveCell) = 0 Then
ActiveSheet.Cells(l + 1, r).FormulaR1C1 = "=IF(R[-1]C="""","""",VLOOKUP(R[-1]C,Etablissements!R1:R1048576,6))"
Else
If Not ActiveSheet.Cells(l + 1, r + 3).HasFormula And Len(ActiveCell) = 0 Then
ActiveSheet.Cells(l + 1, r + 3).Activate
ActiveSheet.Cells(l + 1, r + 3).FormulaR1C1 = "=IF(R[-1]C[-3]="""","""",VLOOKUP(R[-1]C[-3],Etablissements!R1:R1048576,7))"
Else
End If
Exit Sub
End If
End If
End If
End Sub