Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Coding Custom Date Functions in Excel
Hi all,
I've coded up a function in Excel that works in the Immediate Debug window, but not in Excel itself. The function looks up a cell range to see if a date is in the cell range specified ---- Function GetPublicHoliday(InternalDate) As Boolean Dim publicHolidayRange1 As Range Dim findRange Set publicHolidayRange1 = Worksheets("PublicHoliday").Range ("PublicHolidayRange") 'the range I wish to query Set findRange = publicHolidayRange1.Find(What:=InternalDate, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) ' the above should give me a result set based on if the Find method can locate any cells that equal InternalDate GetPublicHoliday = Not (findRange Is Nothing) 'If there is a range found, we return true. If not, we return false. End Function --- While using the debug mode, the function Debug.print(GetPublicHoliday (DateSerial(2009,01,01))) returns TRUE. Unfortunately, if I use it in an Excel formula, say GetPublicHoliday (Date(2009,01,01)), it returns FALSE. Are there any subtle pointer things I need to worry about when using date functions in Excel? Hope you can help, -George |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Custom functions excel 2003 | Excel Worksheet Functions | |||
Using custom functions within custom validation | Excel Discussion (Misc queries) | |||
color coding custom number formats | Excel Discussion (Misc queries) | |||
color coding custom number formats | Excel Discussion (Misc queries) | |||
Custom Functions | Excel Worksheet Functions |