ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Holidays list in a function (https://www.excelbanter.com/excel-programming/378627-holidays-list-function.html)

John Pierce

Holidays list in a function
 
Happy Holidays everyone!
And speaking of which . . . I'm using a Holiday
function that I may have gotten from this group . . .

Public Function IsHoliday(CheckDate, Holidays As Range) As Boolean
'Return Trues if the day, dateTime, is in Holidays List
Dim c As Range
For Each c In Holidays
If DateValue(CheckDate) = c Then
IsHoliday = True
Exit Function
End If
Next c
IsHoliday = False
End Function

The Holidays List is on a sheet in PERSONAL.XLS
The only tiny hitch is that when I use the function it
prompts for the Holidays argument but since this
is always going to be in the same place I would like
this to be automatic. Is that possible by perhaps
including its path in the function?


Bob Phillips

Holidays list in a function
 
Public Function IsHoliday(CheckDate) As Boolean
'Return Trues if the day, dateTime, is in Holidays List
Dim c As Range
For Each c In
Workbooks("Personal.xls").Worksheets("holidays").R ange("A1:A10")
If DateValue(CheckDate) = c Then
IsHoliday = True
Exit Function
End If
Next c
IsHoliday = False
End Function


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"John Pierce" wrote in message
ups.com...
Happy Holidays everyone!
And speaking of which . . . I'm using a Holiday
function that I may have gotten from this group . . .

Public Function IsHoliday(CheckDate, Holidays As Range) As Boolean
'Return Trues if the day, dateTime, is in Holidays List
Dim c As Range
For Each c In Holidays
If DateValue(CheckDate) = c Then
IsHoliday = True
Exit Function
End If
Next c
IsHoliday = False
End Function

The Holidays List is on a sheet in PERSONAL.XLS
The only tiny hitch is that when I use the function it
prompts for the Holidays argument but since this
is always going to be in the same place I would like
this to be automatic. Is that possible by perhaps
including its path in the function?




John Pierce

Holidays list in a function
 
Thanks, Bob, that did the trick.



All times are GMT +1. The time now is 12:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com