Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Lewis Evans   on Sep 03 In MS Office Category.

  
Question Answered By: Candace Foster   on Sep 03

...and to simplify formula...

Sub DateCalc()
Dim LastMon, LastDay, CurYear
Dim ldtStart, ldtEnd
CurYear = Year(Now)
LastMon = Month(Now) - 1
ldtStart = Format(DateSerial(CurYear, LastMon, 1), "MM/DD/YYYY")
ldtEnd = Format(DateSerial(CurYear, LastMon + 1, 1) - 1, "MM/DD/YYYY")
MsgBox ldtStart & Chr(13) & ldtEnd
End Sub

OR...

Sub DateCalc()
Dim ldtStart, ldtEnd
ldtStart = Format(DateSerial(Year(Now), Month(Now) - 1, 1), "MM/DD/YYYY")
ldtEnd = Format(DateSerial(Year(Now), Month(Now), 1) - 1, "MM/DD/YYYY")
MsgBox ldtStart & Chr(13) & ldtEnd
End Sub

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Run Last month report on 5th Or get search suggestion and latest updates.


Tagged: