Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Holiday Dates | Excel Worksheet Functions | |||
Sort a Column of Dates in Pivot Table | Excel Worksheet Functions | |||
count function in pivot table | Excel Discussion (Misc queries) | |||
Recogniziting Dates in an IF function? | Excel Worksheet Functions | |||
if function with dates | Excel Discussion (Misc queries) |