armchairandy
Board Regular
- Joined
- Mar 27, 2012
- Messages
- 53
Hi
I have a code to list all the workdays between two dates, works great. What I need is to add some code that will do the same thing, but ignore any holiday dates held in a seperate sheet "Holidays" as well as weekends.
Sub WorkingDays()
Dim FirstDate As Date
Dim LastDate As Date
Dim NextDate As Date
FirstDate = Range("A2").Value
LastDate = Range("A3").Value
NextDate = FirstDate
Range("C3").Select
'selection of columns within one row
Do Until NextDate > LastDate
ActiveCell.Value = NextDate
ActiveCell.Offset(1, 0).Select
NextDate = WorksheetFunction.WorkDay(NextDate, 1)
Loop
End Sub
Any help would be appreciated
I have a code to list all the workdays between two dates, works great. What I need is to add some code that will do the same thing, but ignore any holiday dates held in a seperate sheet "Holidays" as well as weekends.
Sub WorkingDays()
Dim FirstDate As Date
Dim LastDate As Date
Dim NextDate As Date
FirstDate = Range("A2").Value
LastDate = Range("A3").Value
NextDate = FirstDate
Range("C3").Select
'selection of columns within one row
Do Until NextDate > LastDate
ActiveCell.Value = NextDate
ActiveCell.Offset(1, 0).Select
NextDate = WorksheetFunction.WorkDay(NextDate, 1)
Loop
End Sub
Any help would be appreciated