Return previous working day
This tutorial shows how to return the previous work day (business day) using an Excel formula or VBA
Example: Return previous working day
=WORKDAY(B5,-1,$F$5:$F$12)
|
This formula uses the Excel WORKDAY function, including the holidays, to calculate the previous working day from the selected date. By using -1 for the day criteria the formula will return the previous working day from the selected date.
|
Sub Previous_working_day()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'return the previous working day
ws.Range("C5") = Application.WorksheetFunction.WorkDay(ws.Range("B5"), -1, ws.Range("F5:F12"))
ws.Range("C5") = Application.WorksheetFunction.WorkDay(ws.Range("B5"), -1, ws.Range("F5:F12"))
End Sub
EXPLANATION
This tutorial shows how to return the previous work day (business day) through the use of an Excel formula or VBA.
Both the Excel formula and VBA methods make use of the WORKDAY function to return the previous working day.
FORMULA
=WORKDAY(date,-1,holidays)
=WORKDAY(date,-1,holidays)
ARGUMENTS
date: The initial date from which to begin counting the number of working days.
holidays: A list of dates that specifies the holidays to take into consideration.
date: The initial date from which to begin counting the number of working days.
holidays: A list of dates that specifies the holidays to take into consideration.
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Return next working day | How to return the next work day (business day) using Excel and VBA |