View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
KevHardy KevHardy is offline
external usenet poster
 
Posts: 39
Default WORKDAY question

Hi Rick,
How would I change your code to allow the user to enter a start date and end
date? i.e. the Start and Finish would be from cell contents (G2 and G3
perhaps) rather than DateSerial().
I've tried changing this myself but don't really know what I'm doing :-)

I'm presuming the Dim will be different (Range rather than Date?)

"Rick Rothstein" wrote:

Here is another approach for you to consider (just set the start and finish dates and the holiday named range as needed)...

Sub PopulateWorkdays()
Dim X As Long, Z As Long, Start As Date, Finish As Date, H() As String
H = Split(Join(WorksheetFunction.Transpose(Range("Holi days"))))
Start = DateSerial(2010, 1, 1)
Finish = DateSerial(2010, 12, 31)
For X = Start To Finish
If Weekday(X, vbMonday) < 6 And UBound(Filter(H, X)) < 0 Then
Z = Z + 1
Cells(Z, "A").Value = X
End If
Next
End Sub

--
Rick (MVP - Excel)


"KevHardy" wrote in message ...
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?

.