VBA copier formules à partir de la 1ere ligne vide

neim

XLDnaute Junior
Bonjour à tous,

Avec ce code je recopie des formules dans mon fichier de la ligne 2 à 519. Mais si je modifie une cellule manuellement, elle se retrouve forcément remplcée par la formule ensuite.

Peut-on faire recopier ces formules à partir de la 1ere ligne vide ?

Merci


Option Explicit

Sub Archivage()
Dim i As Long, j As Long
Application.ScreenUpdating = False
If Range("A2") = "" Then
Range("A2").Select
Else
Range("A1").End(xlDown).Select
End If
For i = ActiveCell.Row To 2 Step -1
Sheets("Besoins").Select
If Cells(i, 17) <> "" Then
Range(Cells(i, 2), Cells(i, 17)).Copy
Sheets("Archives").Select
Range("B519").End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Besoins").Select
Range(Cells(i, 1), Cells(i, 17)).Delete
End If
Next i
Sheets("Besoins").Select
For j = 2 To 519
Cells(j, 1).FormulaR1C1 = "=IF(RC[1]="""","""",IF(RC[1]=R[-1]C[1],R[-1]C,R[-1]C+1))"
Cells(j, 11).FormulaR1C1 = "=IF(RC[-10]="""","""",IF(RC[-3]-RC[-1]<0,0,RC[-3]-RC[-1]))"
Cells(j, 14).FormulaR1C1 = "=IF(RC[-12]="""","""",IF(COUNTIF(C[-8]:C[-8],RC[-8])>1,(SUMIF(C[-8]:C[-6],RC[-8],C[-6]:C[-6])-SUMIF(C[-8]:C[-1],RC[-8],C[-1]:C[-1])),""""))"
Cells(j, 16).FormulaR1C1 = "=IF(AND(RC[-11]<TODAY(),RC[-1]<TODAY(),RC[-1]<>""""),""Retard composant et livraison"",IF(AND(RC[-11]<TODAY(),RC[-11]<>""""),""Retard livraison"",IF(AND(RC[-1]<>"""",RC[-1]<TODAY()),""Retard composant"","""")))"
Next j
Application.ScreenUpdating = True
End Sub
 

Discussions similaires

Réponses
14
Affichages
621
Réponses
11
Affichages
396

Statistiques des forums

Discussions
311 733
Messages
2 082 010
Membres
101 866
dernier inscrit
XFPRO