VB Workdays

Nomis_Eswod

Board Regular
Joined
Jul 27, 2005
Messages
153
Hi,

I have a form with some text boxes on it. In one text box is a date, this is automatically populated with the days date when it is entered. Another box contains a number, which is the amount of days expected to complete a task. What I do is add the number to the date to get another date so I know when I need to complete the task by.

What I want to do is calculate the future date in working days, i.e. not counting weekends. Do you know if there is anyway to do this in VBA?

Thanks,
Me
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
L

Legacy 98055

Guest
In it's simplest form...

Code:
Function GetFinishDate(StartingDate As Date, Days As Double) As Date
    Dim OffDaysCnt As Double
    
    Do
        If Weekday(StartingDate, vbSaturday) > 2 Then Days = Days - 1
        StartingDate = StartingDate + 1
    Loop While Days > 0
    
    GetFinishDate = DateAdd("d", OffDaysCnt - 1, StartingDate)
End Function

Tweek it to not include the first day and to take into account holidays if you need to...
 
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,163,990
Messages
5,834,761
Members
430,317
Latest member
karenmi

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