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

Just spotted a bug in that try this instead

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
Sht.Cells(x, 1) = WorksheetFunction.WorkDay(Sht.Cells(x, 1), 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?