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
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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...
 

Watch MrExcel Video

Forum statistics

Threads
1,118,068
Messages
5,570,002
Members
412,304
Latest member
citrus
Top