Sub Remplissage()
Range[B][COLOR=blue]("a2", "j500").[/COLOR][/B]ClearContents
Dim Début As Date, Fin As Date, DateIntermédiaire As Date, [COLOR=red][B]Hauteur As Double[/B][/COLOR], I As Integer
On Error GoTo Sortie
Début = InputBox("Date de début ?")
Fin = InputBox("Date de fin ?")
On Error GoTo 0
If Fin < Début Then Exit Sub
DateIntermédiaire = Début
Hauteur = ((Month(Fin) + Year(Fin) * 12) - (Month(Début) + Year(Début) * 12) [COLOR=red][B]+ 1[/B][/COLOR]) / 3
If Hauteur <> Int(Hauteur) Then Hauteur = Int(Hauteur) [COLOR=red][B]+ 1[/B][/COLOR]
For I =[B][COLOR=blue]2[/COLOR][/B]To Hauteur [B][COLOR=blue]+ 1[/COLOR][/B]
Cells(I, 3) = DateIntermédiaire
Cells(I, 6) = DateAdd("m", Hauteur, DateIntermédiaire)
If DateAdd("m", Hauteur * 2, DateIntermédiaire) <= Fin Then
Cells(I, 9) = DateAdd("m", Hauteur * 2, DateIntermédiaire)
End If
DateIntermédiaire = DateAdd("m", 1, DateIntermédiaire)
Next I
For I = [COLOR=blue][B]2[/B][/COLOR] To Hauteur [COLOR=blue][B]+ 1[/B][/COLOR]
If Month(Cells(I, 3)) = Month(Début) Then Cells(I, 1) = Year(Cells(I, 3)) - Year(Début)
If Month(Cells(I, 6)) = Month(Début) Then Cells(I, 5) = Year(Cells(I, 6)) - Year(Début)
If Month(Cells(I, 9)) = Month(Début) Then Cells(I, 8) = Year(Cells(I, 9)) - Year(Début)
Next I
Exit Sub
Sortie: Exit Sub
End Sub