Return previous day based on a date

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

Example: Return previous day based on a date

Return previous day based on a date

METHOD 1. Return previous day based on a date

EXCEL

=TEXT(B5-1,"dddd")
This formula uses the Excel TEXT function with the "dddd" criteria to return the previous day based on a specific date. 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 9.

METHOD 1. Return previous day based on a date using VBA

VBA

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

End Sub

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code.
Date: Select the date from which to return the previous day 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 a date 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 return previous day based on a date

EXPLANATION

EXPLANATION

This tutorial shows and explains how to return the previous day based on a specific date using an Excel formula or VBA.
This tutorial provides one Excel method that can be applied to return the previous day based on a specific date with the use of the TEXT function. The formula initially subtracts one day from the selected date to return the prior date, by one day, and 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 a date.
FORMULA
=TEXT(date-1),"dddd")
ARGUMENTS
date: The date from which to return the previous day.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to return the previous day based on the current day using Excel and VBA methods
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

RELATED FUNCTIONS

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