Sub DateBudget()
Application.DisplayAlerts = False
Dim annee As String
Sheets("Calculs").Select [COLOR="Green"]'C'est la feuille depuis laquelle on lance l'ensemble des calculs[/COLOR]
annee = Range("M28") [COLOR="Green"]'C'est là que l'année à prendre en compte pour le budget se trouvera.[/COLOR] Sheets("Matrice Budget").Select [COLOR="green"]'C'est cette feuille qui contient les formules à modifier[/COLOR]
Set X = ActiveSheet.Cells.Find(What:="[budget2", LookIn:=xlFormulas, LookAt:=xlPart)
If Not X Is Nothing Then
firstAddress = X.Address
Do
Debut = InStr(1, X.Formula, "[budget2")
ancien = Mid(X.Formula, Debut, 11)
Application.DisplayAlerts = False
X.Value = Application.Substitute(X.Formula, ancien, "[budget2" & Right(annee, 3))
[COLOR="green"]'(J'ai dû demander à trouver "budget2" pour pas qu'il confonde donc j'enlève le "2" de
'la date. Ca ne fonctionnera plus en l'an 3000 mais c'est acceptable[/COLOR]
Set X = ActiveSheet.Cells.FindNext(X)
Loop While Not X Is Nothing And X.Address <> firstAddress
End If
Set X = ActiveSheet.Cells.Find(What:="Budget global", LookIn:=xlFormulas, LookAt:=xlPart)
If Not X Is Nothing Then
firstAddress = X.Address
Do
Debut = InStr(1, X.Formula, "Budget global")
ancien = Mid(X.Formula, Debut, 18)
X.Value = Application.Substitute(X.Formula, ancien, "Budget global " & annee)
[COLOR="green"]'C'est ton code[/COLOR]
Set X = ActiveSheet.Cells.FindNext(X)
Loop While Not X Is Nothing And X.Address <> firstAddress
End If
Sheets("Calculs").Select
Application.DisplayAlerts = True
End Sub