command button help

Sorry please can you help me list the 1st and last day of the month; at the moment I got the 1st monday and last friday.

Private Sub CommandButton1_Click()

Dim dtFirst As Date
Dim dtLast As Date

        dtFirst = DateSerial(Year(Date), Month(Date), 1)
        dtLast = DateSerial(Year(Date), Month(Date) + 1, 0)
       
       Range("C2").Value = dtFirst + 6 - Weekday(dtFirst - 1, 3)
       
       Range("C3").Value = dtLast + 1 - Weekday(dtLast + 1 - 6)

End Sub
Kiwi-123Asked:
Who is Participating?
 
nutschCommented:
Is this what you need?

Private Sub CommandButton1_Click()

Dim dtFirst As Date
Dim dtLast As Date

        dtFirst = DateSerial(Year(Date), Month(Date), 1)
        dtLast = DateSerial(Year(Date), Month(Date) + 1, 0)
       
       Range("C2").Value = dtFirst
       
       Range("C3").Value = dtLast

End Sub 

Open in new window

0
 
Martin LissOlder than dirtCommented:
Take a look here.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.