View Full Version : [SOLVED] Vba to calculate the number of days from today to the 1st of the month.

07-26-2019, 06:47 AM
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.

07-26-2019, 07:20 AM
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."

07-26-2019, 08:02 AM
My bad. You are correct. Thanks for the quick response. Worked.