Previous Thursday Date using VBA Functions

Previous Thursday Date

VBA get Previous Thursday Date with vbSunday, vbMonday, vbThursday, vbThursday, vbThursday, vbFriday and vbSaturday in Excel using VBA Functions. We run so many reports manually or by scheduling reports as part of our daily activities. Sometimes we want to run or schedule reports on specific day in a week.

Lets assume you want to run reports on Thursday. This tutorial I am going to explain how to find last or previous Thursday Date using VBA Formulas. We run report based on weekday date, If the output word matches with specified weekday then continue run the report, otherwise it ignores.

Previous Thursday Date

Get Previous Thursday Date using VBA Functions

Let us see different statements to find Date of Last or previous Thursday using Excel VBA. Lets assume today is 3rd December 2018(03/12/2018). The below macro example produces same result. i.e 29th November 2018(29/11/2018).

'Previous Thursday Date using Excel VBA Functions
Sub VBA_Find_previous_Thursday()

     Dim dPrevious_Thursday As Date
     
    dPrevious_Thursday = DateAdd("ww", -1, Now - (Weekday(Now, vbSunday) - 5))
    Debug.Print dPrevious_Thursday
    'Or
    dPrevious_Thursday = DateAdd("ww", -1, Now - (Weekday(Now, vbMonday) - 4))
    Debug.Print dPrevious_Thursday
    'Or
    dPrevious_Thursday = DateAdd("ww", -1, Now - (Weekday(Now, vbTuesday) - 3))
    Debug.Print dPrevious_Thursday
    'Or
    dPrevious_Thursday = DateAdd("ww", -1, Now - (Weekday(Now, vbWednesday) - 9))
    Debug.Print dPrevious_Thursday
    'Or
    dPrevious_Thursday = DateAdd("ww", -1, Now - (Weekday(Now, vbThursday) - 8))
    Debug.Print dPrevious_Thursday
    'Or
    dPrevious_Thursday = DateAdd("ww", -1, Now - (Weekday(Now, vbFriday) - 7))
    Debug.Print dPrevious_Thursday
    'Or
    dPrevious_Thursday = DateAdd("ww", -1, Now - (Weekday(Now, vbSaturday) - 6))
    Debug.Print dPrevious_Thursday
    
    MsgBox "If today's date is 12/03/2018 " & vbCrLf & " then previous Thursday's date is " _
    & Format(dPrevious_Thursday, "DD MMMM YYYY"), vbInformation, "Previous Thursday Date"

End Sub

In the above macro we have used different vba functions like DateAdd, Now, Weekday and Format in multiple statements. You can view immediate window, it displays same output.

Note: Use Shortcut ‘Ctrl + G’ for an Immediate window.

Output Screenshot: Please find the output screenshot of above specified macros.

Previous Thursday Date

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays VBA Text Files VBA Tables

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog

Leave a Comment