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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

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)
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

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
Back
Top