Sub Set_Formula()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
With Sheets("IMPORT")
fin = .UsedRange.Rows.Count 'dernière ligne de la feuille Import
For i = 2 To fin 'pour chaque ligne de la feuille IMPORT
formuleO = "" 'on initialise les formules
formuleX = ""
formuleY = ""
formuleN = ""
SLACode = .Range("J" & i) 'récupère le code SLA en colonne J
Set trouve = Sheets("FORMULES").Range("A:A").Find(SLACode, lookat:=xlWhole) 'on cherche le code dans la colonne A due la feuille "FORMULES"
If Not trouve Is Nothing Then 'si on l'a trouvé, on récupère les formules sur la ligne
formuleO = Sheets("FORMULES").Range("B" & trouve.Row).Formula
formuleX = Sheets("FORMULES").Range("C" & trouve.Row).Formula
formuleY = Sheets("FORMULES").Range("D" & trouve.Row).Formula
formuleN = Sheets("FORMULES").Range("E" & trouve.Row).Formula
.Range("O" & i).Formula = Replace(formuleO, trouve.Row, i) 'on applique la formule dans la feuille IMPORT en modifiant les indices de la formule
.Range("X" & i).Formula = Replace(formuleX, trouve.Row, i)
.Range("Y" & i).Formula = Replace(formuleY, trouve.Row, i)
.Range("N" & i).Formula = Replace(formuleN, trouve.Row, i)
End If
Next i
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub