Public Function LastDayOfMonth(Year As Integer, Month As Integer) LastDayOfMonth = DateAdd("d", -1, _ DateAdd("m", 1, DateSerial(Year, Month, 1))) End Function