Private Sub Worksheet_Change(ByVal Target As Range)
Dim col&, quoi, i&
If Intersect(Target, Columns("a:b")) Is Nothing Then Exit Sub
If Range("b1") = "" Or Range("b2") = "" Then Exit Sub
On Error GoTo FIN
Application.EnableEvents = False: Application.ScreenUpdating = False
If Range("a5") <> "" Then
quoi = Format(Range("a5"), "mmyyyy")
col = Application.Match(quoi, Sheets("Bdd").Rows(1), 0)
Range("b5").Resize(31).Copy Sheets("Bdd").Cells(2, col)
End If
quoi = Format(DateSerial([b1], [b2], 1), "mmyyyy")
col = Application.Match(quoi, Sheets("Bdd").Rows(1), 0)
Sheets("Bdd").Cells(2, col).Resize(31).Copy Range("b5")
Range("a5").Resize(31).ClearContents
Range("a5") = DateSerial([b1], [b2], 1)
For i = 2 To Day(DateSerial([b1], [b2] + 1, 0)): Range("a5").Offset(i - 1) = Range("a5") + i - 1: Next
FIN:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim n&, xrg As Range
n = Application.Count(Range("a5:a35"))
If n = 31 Then
If Not Intersect(Target, Range("a5").Resize(31)) Is Nothing Then Range("a3").Select: Beep
Else
Set xrg = Range("b5").Offset(n).Resize(31 - n, 1)
Set xrg = Union(xrg, Range("a5").Resize(31))
If Not Intersect(Target, xrg) Is Nothing Then Range("a3").Select: Beep
End If
End Sub