# VBA Code To Return Previous Friday And Month Before Date

May 8, 2014

How to write a VBA code so that it would calculate the date of the previous Friday and from there Return the date exactly 1 month before; on any given day.

For example...
today is may 8th

So if I run the code the dates returned for last friday should be 05/02/2014
and 04/04/2014 should be returned AS the DATE exactly a month from 05/02/2014

## Return Last Friday From A Given Month

May 23, 2007

Re: Return last Friday from a given month
This will calculate the last Friday of the month in which the date in A1 falls:

=DATE(YEAR(A1),MONTH(A1)+1,0)+MOD(-WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,0),2)-2,-7)

HTH

TJ

actually this thread is closed. I want to convert this into UDF but not able.

## Get Date Of Last Friday In Month?

Mar 25, 2012

If there's one thing I really wish I understood more in Excel its how to use formulas to calculate days and times.

I'm looking for a formula that will give me the date of the last Friday in a month based on another date. I have the formula below at the moment that works quite nicely for March 2012 but not for any others. It's getting the 5 at the end to be more flexible that's got me stumped.

=DATE( YEAR(H12), MONTH(H12) + 1, 0) - (WEEKDAY( DATE( YEAR(H12), MONTH(H12) + 1, 0), 2) - 5 )

## Determining Date Of 2nd Or Last Friday Of Any Month?

Sep 14, 2008

Without VB, is there a way to write a formula which when given a certain month, will output the date of, let's say, 2nd or last friday of the month?

## Calculate Date Of Next Occurring 3rd Friday Of Month?

Oct 18, 2013

I am trying to calculate the Date of the next occurring 3rd Friday of the month in relation to a Static Date in a cell. So if Static Date in cell is Tuesday of the second week of a month, then I am trying to return the date of the 3rd Friday of that month. If the static date in the cell is the third friday of the month, I just want to return that particular date. And if the static date is after the 3rd Friday of the month, I am trying to return the 3rd friday of the following month. So far here is the formula I am using:

Code:
=DATE(YEAR(A2),MONTH(A2),14+CHOOSE(WEEKDAY(DATE(YEAR(A2),MONTH(A2),4)),2,1,7,6,5,4,3))

The problem I have is that if the static date is after the third friday of the month, this continues to return the 3rd friday of the month of the static date and does not advance to the third friday of the following month. Looks like I cannot attached a sample spreadsheet but here is a screenshot of the sample sheet:

[URL]

## Formula Return Following Wednesday Or Friday Date

Jun 10, 2008

Need a formula for cell J27 that returns the date of the following Wednesday from a date in cell J2 that's a Wed, Thurs, or Fri
or
return the date of the following Friday for a date in cell J2 that's Sat, Sun, Mon, or Tue.

For example, when 05-29-08, a Thursday, is entered in cell F2, I need cell J27 to return the following Wednesday's date of 6-04-08.
or
For example, when 06-01-08, a Sunday, is entered in cell F2, I need cell J27 to return the following Friday's date of 06-06-08.

## Count Date Cells Where Date Is Previous Month

Oct 25, 2006

I have a spreadsheet which I use to track when a work request is recieved, when we confirm the request and when we action the request. I have been trying to write some code to count the amount of requests, receipts and actions we have processed in the last month.

My first column shows who the request is from
The second shows date recieved
The third shows date we send receipt
The fourth shows the date actioned.

## Highlight Date If Previous Month

Mar 13, 2008

Need to be able to highligh data within a range where the date in a column is for the previous month/s- therefore need to be able to also include in macro entering the current month - don't want to have to edit macro each month

## Auto Calculate End Date Of Previous Month

Jan 28, 2009

I have a cell in which I will input the last day of a month (e.g., 1/31/09, 2/28/09, etc.) In another cell, I want Excel to show the last day of the previous month. Is there a formula to calculate this automatically?

I enter in Cell 1: 1/31/09
Excel calculates in Cell 2: 12/28/08

I enter in Cell 1: 2/28/09
Excel calculates in Cell 2: 1/31/09

## Check Whether Date Is A Month After Previous Date?

Dec 12, 2013

I'm sent a file every day where column A contains a month & year but in "general" format.

For example;

Column A, starting with cell A1 with the next date in A2, etc
Jan15
Feb15
Mar15
Apr15

Is there a way through a formula or macro that I can use in order to run through all the dates in this column to make sure that the next cell down is always the month after the cell above it? The dates go all the way through to 2018 in the above format.

## Calculate 1st Tuesday Or 3rd Friday Of Month

Nov 11, 2009

I am trying to construct a schedule of tasks to be done by certain dates. If the last day of the month is entered (say 11/31/09) in a cell, is it possible to find out the date for the third Thursday of November or the first Wednesday or the last Friday?

## First Monday, Thursday, And Friday Of Month

Jan 17, 2008

In cell A1 I have a date (like 8/1/08)

In A3, B3, and C3 I need to have the first Monday, Thursday, and Friday of the month. Here's the caveat, I need A3 to have the day that comes earliest in the month.

In this case, A3 would contain 8/1/08 since it's the first Friday, B3 would have 8/4/08 as the first Monday, then C3 would have 8/7/08 as the first Thrusday.

If A1 contained 7/1/08 then A3 would have 7/3/07 as the first Thursday with Friday and Monday following.

## Macro: Return Previous Working Days Date

Dec 1, 2006

how do i get the previous days working date in VBA, how can i get VBA to determine wether we are in the week, and how will i get it to know its a monday to retrieve fridays date?

## VBA Code To Add 1 To The Previous Date

Jan 4, 2010

I have a folder containing excel files with dynamic suffix names. I have files for all days starting from the 1st of the month – for example : Performance_01012010.xls, Performance 02012010.xls, Performance_03012010.xls till Performance_31012010.xls.

I want a VBA code to retrieve the date out and change it automatically (means it should add 1 automatically to the previous date). For example, if I open Performance_05012010.xls, my macro should SAVE AS this file to Performance_06012010.xls.

## Code To Clear Previous Date

Feb 24, 2013

I have a Userform that exports data. I tried adding the following code to clear the export sheet each time and it crashes:

Set Popul = Sheets("Sheet2").Range(("a2"), Range("A2").End(xlDown))
Popul.EntireRow.ClearContents

Additionally I want to leave the top row as it has titles that will be needed.

## Populating A Cell With A Calendar Month Based On The Previous Date In Another Cell.

Jan 9, 2010

Trying to word this right. I have one cell with a date of 01/01/2010. I have other cells that I want to be equal to this cell plus 1 or more months.

For example A1=01/01/2010

I want A2 to = 02/01/2010 based on one calendar month entered into A1. So if A1 changes 03/01/2010, A2 will = 04/01/2010.

## If Date Is Between 1st Through 1th Of Month Return Value

Jul 31, 2014

If I make a sale between the 1st of each month through the 1th of each month I will be paid on the 31st of that month. If I make a sale on the 16th of each month through to the last day of each month I will be paid on the 15th of the next month. I need this formula to work for every month.

cell e has date of sale
cell h has the returned value of the formula above

## Return Date Of 3rd Day Of Following Month

Jun 27, 2012

I need to return the date of the third day of the month following the date in cell a1:

So, If A1= 06/01/12
A2 should = 07/03/12

## Return Date Of Specified Day In Month

Sep 13, 2007

Is there a end of "week" function which shows only the date the friday? says ..if today is 9/13/2007, the cell will show 9/7/2007...

## Return Date Of Last Day Of Given Month

Oct 16, 2007

I'm after a formula(s) which will give the start date and end date of a month using the month name. For instance, if cell A1 contained OCTOBER 07 the formula result for the start of the month would be 01/10/07 and the formula for the end of the month would be 31/10/07. I have plyed around with the EOMONTH function but this only workd when an actual date is entered.

## Move Date To Next Monday If Date Is On Friday / Saturday Or Sunday

Aug 24, 2014

I have a list of dates and I need a formula that will return the date of the following Monday, IF the date falls on a Friday, Saturday or Sunday.

## Return The Month Integer From A Date

Aug 5, 2008

Upon trying to use the Month function (to return the month integer from a date), in excell 2007, I get the

"Expected variable or procedure, not module

followed by (if I drill down into the help file)

There is no variable or procedure by this name in the current scope, but there is a module by this name"

error message

Do I assume there is a way around this (or if I have to do something to 'activate' the month function)

## Find Pay Date From Date Sold (Friday Of Following Week)

Feb 17, 2014

If a sale was made between 2/09/2014 - 2/15/2014 return the date of the following weeks Friday. In this case 02/21/2014.

## Enter A Date And Return The Fiscal Month

Dec 15, 2008

Is there any way to defined our own fiscal month. I have a fiscal year where the start & end date is different from the normal calendar. I have store the start & end date on the different column. What i need is that when people enter a date, it will look up to the table and return the fiscal month.It's something like If the value is >=column A and <=column B, then the fiscal month=column C(refer to the below table). But i have no idea how to make comparison on date value. what kind of formula i should use? And also how to write the code if i want to use macro to implement this?

Start End Month
09/21/08 10/18/08 Oct
10/19/08 11/22/08 Nov
11/23/08 12/27/08 Dec
12/28/08 01/24/09 Jan
01/25/09 02/21/09 Feb
02/22/09 03/28/09 Mar
03/29/09 04/25/09 Apr
04/26/09 05/23/09 May
05/24/09 06/27/09 Jun
06/28/09 07/25/09 Jul
07/26/09 08/22/09 Aug
08/23/09 09/26/09 Sep

## Return A Date Based On Year / Month

Jan 21, 2009

formula off here i use all the time relating to finding and sumproducts for specific months and years i.e.

Jan 2008, Dec 2007.. depending on these dates excel searched through a specified range and returned me any values i wanted like No. of occurences, totals, sums etc etc it was a sumproduct formula...

is there any way i could specifiy a date i.e. Jan 2009, which would search column a and return the date /and/or an account number in column b, only if the date was during jan 2009?

The reason i want this is to use a lookup on the account numbers to return specific items of info, but i only need the account numbers if they occurred in specific months which i want to choose.

## Excel 2003 :: Getting Formula Which Will Return Each Date Of Month

Sep 10, 2013

I have a cell (A1) which contains the month. A2 contains the year. I need a formula which will return each date of the month.

## Return Month Number Of Date Unless Cell Empty

Apr 9, 2008

I am using the MONTH function in a formula. The Month value of an empty cell is returned as "1". Why is this? Is there any way to return a null value or zero?

## How To Get Last Friday Date Based On Current Date

Feb 14, 2013

I need to work out how to get the last (or most recent) Friday date. Suppose today is 14/02/2013, then the previous date is: 08/02/2013. If today is 15/02/2013, then I just want it to be 15/02/2013 as it is Friday.

## VB Code To Add Month To Date

Oct 3, 2012

In cell E1, I have the month displayed. In cell I50, when I add the date of say the 5th, I want it to add the month to it so it will read, 10/5 or 5-Oct. This will be true for cells I50:I164

## Returning The Date For Last Friday?

Feb 12, 2008

how to write an excel workbook function that will return last friday's date?

For example: If Today is 2/12/2008, it will return 2/8/2008 as the date