Consulting

Results 1 to 3 of 3

Thread: Vba to calculate the number of days from today to the 1st of the month.

  1. #1
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location

    Question Vba to calculate the number of days from today to the 1st of the month.

    I am trying locate VBA to calculate the number of days between the current date & the first of the month. I.e. There 5 days between 7/27/2019 & 8/1/2019.
    My goal is have a Msg Box say "there are 5 days left in the current month." I have located code for static dates, but nothing for dynamic dates.

  2. #2
    VBAX Regular
    Joined
    Feb 2013
    Posts
    52
    Location
    Actually there are only 4 days between 7/27/2019 & 8/1/2019 but if you need it to be 5
    use Excel's built in EOMonth function and add 1
    MsgBox "there are " & CDbl(Application.EoMonth(Date, 0) - Date) + 1 & " days left."

  3. #3
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location
    My bad. You are correct. Thanks for the quick response. Worked.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •