View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default WORKDAY question

Hi

Change Sht to the sheet you want and manually populate your holidays in the
range E1 - E10 then run the code and you get your list of workdays in col A.
They will start from the date after the variable MyDate

Sub MyMacro()
Set Sht = Sheets("Sheet1")
Dim MyDate As Date
MyDate = #12/31/2009#
For x = 1 To 365
Do
Sht.Cells(x, 1) = WorksheetFunction.WorkDay(MyDate, 1)
If WorksheetFunction.CountIf(Sht.Range("E1:E10"), Sht.Cells(x, 1)) 0 Then
MyDate = MyDate + 1
End If
Loop Until WorksheetFunction.CountIf(Sht.Range("E1:E10"), Sht.Cells(x, 1)) = 0
MyDate = Sht.Cells(x, 1).Value
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"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?