View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default WORKDAY question


You can use code similar to the following.

Sub AAA()
Dim R As Range
Dim StartDate As Date
Dim NumDays As Long
Dim N As Long
Dim Holidays() As Variant

Holidays = Range("E1:E10") '<<< CHANGE
StartDate = DateSerial(2010, 1, 1) '<<< CHANGE
NumDays = 30 '<<< CHANGE
Set R = Range("A1") '<<< CHANGE

On Error Resume Next
For N = 0 To NumDays
If Weekday(StartDate + N, vbMonday) <= 5 Then
If IsError(Application.Match(StartDate + N, Holidays, 0))
Then
R.Value = StartDate + N
Set R = R(2, 1)
End If
End If
Next N
End Sub

Change the lines marked with <<< to your values. Holidays is the range
that contains the holidays to exclude, StartDate is the first date at
which the list is to begin. NumDays is the number of weekdays to
include in the list, and R is the cell in which the list is to begin.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Sun, 21 Feb 2010 13:08:01 -0800, KevHardy
wrote:

I have used the workday function to populate column A with just workdays
(also used a named list of holidays to exclude).
I was wondering if anyone had a bit of vba to automate this process?