Bonjour à tous et à toutes, forumiens, forumiennes,
Le code trouve le dernier jour du mois : le 30, 31 ou encore le 29 parfois même le 28.
Mais il oublie des mois : 29/09/2006, 29/12/2006, etc…
Comment rectifier ?
Merci d’avance
Sub ChercheDate()
Dim Annee As Date, Mois As Date
Dim NbJours As Byte, i As Byte
Dim Cell As Range
For Each Cell In Range("A2", Range("A2").End(xlDown))
Annee = Year(CDate(Cell))
Mois = Month(CDate(Cell))
NbJours = Day(DateSerial(Year(CDate(Cell)), Month(CDate(Cell)) + 1, 0))
If Format((DateSerial(Annee, Mois, NbJours)), "dd/mm/yyyy") = CDate(Cell) Then
i = i + 1
Cells(i, 3) = Cell
End If
Next Cell
End Sub
Le code trouve le dernier jour du mois : le 30, 31 ou encore le 29 parfois même le 28.
Mais il oublie des mois : 29/09/2006, 29/12/2006, etc…
Comment rectifier ?
Merci d’avance
Sub ChercheDate()
Dim Annee As Date, Mois As Date
Dim NbJours As Byte, i As Byte
Dim Cell As Range
For Each Cell In Range("A2", Range("A2").End(xlDown))
Annee = Year(CDate(Cell))
Mois = Month(CDate(Cell))
NbJours = Day(DateSerial(Year(CDate(Cell)), Month(CDate(Cell)) + 1, 0))
If Format((DateSerial(Annee, Mois, NbJours)), "dd/mm/yyyy") = CDate(Cell) Then
i = i + 1
Cells(i, 3) = Cell
End If
Next Cell
End Sub