Return previous day based on current day

This tutorial shows how to return the previous day based on the current day through the use of an Excel formula or VBA

Example: Return previous day based on current day

Return previous day based on current day

METHOD 1. Return previous day based on current day

EXCEL

=TEXT(TODAY()-1,"dddd")
This formula uses a combination of Excel TEXT and TODAY functions to calculate the previous day based on the current day. The formula uses the TODAY function to return today's date and then removes one day. This will return yesterdays date, which in this case would be 25/01/2019. Then using the TEXT function with the "dddd" criteria the formula returns the day from the date, which in this example in Friday. Please note if you want to return the day number you will need to replace the "dddd" criteria with "d", which in this example will return a number of 25.

METHOD 1. Return previous day based on current day using VBA

VBA

Sub Previous_Day_based_on_Current_Day()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'return the previous day based on the current day
ws.Range("B5") = Format(DateAdd("d", -1, Date), "dddd")

End Sub

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("B5") in the VBA code.
Worksheet Selection: Select the worksheet where you want to return the previous day based on the current day by changing the Analysis worksheet name in the VBA code. You can also change the name of this object variable, by changing the name 'ws' in the VBA code.

Explanation about the formulas used to calculate previous day based on current day

EXPLANATION

EXPLANATION

This tutorial shows and explains how to calculate the previous day based on the current day using an Excel formula or VBA.
This tutorial provides one Excel method that can be applied to return the previous day based on the current day with the use of the TEXT and TODAY functions. The TODAY function is used to return today's date and then we subtract a single day to return yesterdays date. Then using the TEXT function with the "dddd" criteria the formula returns the day.

Please note if you want to return the day number you will need to replace the "dddd" criteria with "d".

This tutorial provides one VBA method that can be applied to return the previous day based on the current day.
FORMULA
=TEXT(TODAY()-1),"dddd")

RELATED TOPICS

Related Topic Description Related Topic and Description
How to return the next month based on the current month using Excel and VBA methods
How to return the previous month based on a specific date using Excel and VBA methods
How to return the previous month based on the current month using Excel and VBA methods
How to return the next month based on a specific date using Excel and VBA methods
How to calculate the difference in years between two dates using Excel and VBA methods

RELATED FUNCTIONS

Related Functions Description Related Functions and Description
The Excel TEXT function returns a numeric value as text, in a specified format
The Excel TODAY function returns the current date