Dim firstDateofMonth As Date
Dim lastDateofMonth As Date
firstDateofMonth = DateSerial(Year(Date), Month(Date), 1)
lastDateofMonth = DateAdd("m", 1, DateSerial(Year(Date), Month(Date), 1)) - 1
Debug.Print firstDateofMonth, TypeName(firstDateofMonth)
Debug.Print lastDateofMonth, TypeName(lastDateofMonth)
解法可能不只一種, 我只是寫出對我來說可讀性最高的一種
firstDateofMonth = cdate(format(date,"yyyy/mm/") & "01")
這也是一種可行的寫法