Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Sorbit
 
Posts: n/a
Default VBA Function that ignores dates in a Holiday Table

I am currently using the code below in an Access Module to query data
for the previous day and not have to change to Date()-3 each Monday and
then back to Date()-1 after running all my Monday reports. It works
great, both with a Holidays table or without it. The code also works as
an Excel VBA function to call a date that does not include Saturdays
and Sundays. However, I cannot make it call the holiday table in
Access. Is there a way to do this? Or would it be simpler to somehow
name a table in Excel (on a separate spreadsheet) and somehow call that
range to make the function ignore an additional day; if the previous
day turns out to be a holiday? Anybody know?

Public Function AdjWorkDays(dteStart As Date, _
intNumDays As Long, _
Optional blnAdd As Boolean = True) As Date
AdjWorkDays = dteStart
Do While intNumDays 0
If blnAdd Then
'-- Adding WorkDays
AdjWorkDays = AdjWorkDays + 1
Else
'-- Subtracting WorkDays
AdjWorkDays = AdjWorkDays - 1
End If
If Weekday(AdjWorkDays, vbMonday) <= 5 Then
'-- Use the following code if you have a "Holiday" table
' If Weekday(dteCurrDate, vbMonday) <= 5 And
IsNull(DLookup("[Holiday]", "tblHolidays", "[HolDate] = #" &
dteCurrDate & "#")) Then
intNumDays = intNumDays - 1
End If
Loop
End Function

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Holiday Dates Alpur Excel Worksheet Functions 3 November 16th 05 06:14 PM
Sort a Column of Dates in Pivot Table Linny Excel Worksheet Functions 2 September 23rd 05 01:24 AM
count function in pivot table Holly Excel Discussion (Misc queries) 1 August 11th 05 11:51 PM
Recogniziting Dates in an IF function? Lowkey Excel Worksheet Functions 2 June 1st 05 04:29 AM
if function with dates Brad Excel Discussion (Misc queries) 1 January 10th 05 10:49 PM


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"