I am trying to create a program that will gather Date information, based on present date, minus date a project was started on. This program will only count "Workdays" as in Monday - Friday, so I need to create a subroutine to handle this. I have tought of an algorythm but I haven't been able to figure out how to Add the days to the date as I do my loop. This is what I have come up with.
Function GetWorkDays(Date1 As Date, date2 As Date)
Dim Range As Integer
Dim DayNumbers As Integer
Dim OneMoreDay As Double
OneMoreDay = DateValue(Date1)
DayNumbers = 0
Range = DateValue(date2) - DateValue(Date1)
Do While Range >= 1
If Weekday(Date1) > 1 Or Weekday(Date1) < 7 Then
OneMoreDay = OneMoreDay + 1
DateValue(Date1) = OneMoreDay '<-- This is where I want to "Add One Day" and continue the loop
DayNumbers = DayNumbers + 1
Range = Range - 1
I have tried everything from AddDate to DateValue functions. AddDate will only "Show" me the next day, but it won't "save" the date into the variable to continue the loop and count only the "WorkDays" for the project. If anyone can help I would greatly appreciate it.