First working day of the previous month

a_mahey

Board Regular
Joined
Dec 2, 2014
Messages
51
Hello all,

Can someone help in defining a VBA variable which will return a date which will be the first working date of the last month. So for example, today's date is 01/06/2015 but I want the variable to return based on today's date the first working day of last month which is 01/05/2015 which was a Friday.

many thanks in advance
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,142
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS

Excel 2013
AB
101-Jun-1501-May-15
201-Jul-1501-Jun-15
301-Dec-1502-Nov-15
Sheet5
Cell Formulas
RangeFormula
B1=WORKDAY(EOMONTH(A1,-2),1)
 

a_mahey

Board Regular
Joined
Dec 2, 2014
Messages
51
thanks a lot - could you please help to define it in VBA.

Regards
 

Momentman

Well-known Member
Joined
Jan 11, 2012
Messages
4,142
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
thanks a lot - could you please help to define it in VBA.

Regards
Maybe

Excel 2013
AB
101-Jun-1501/05/2015
201-Jul-1501/06/2015
301-Dec-1502/11/2015
Sheet7
Cell Formulas
RangeFormula
B1=FirstWrkDay(A1)

and the UDF is
Code:
]
Function FirstWrkDay(sedate As Date)
    Application.Volatile
    Dim wf As WorksheetFunction
    Set wf = Application.WorksheetFunction
    FirstWrkDay = Format(wf.WorkDay(wf.EoMonth(sedate, -2), 1), "dd/mm/yyyy")
End Function
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,323
Messages
5,836,637
Members
430,442
Latest member
Zephreo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top