LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default #VALUE! from Function()


I've written a function() that validates the interrelationship
between 3 cells. If the data is valid, the function looks up
the date from one of the cells in a table of holidays and
returns the name of the holiday. It's acceptable for all
3 cells to be empty (no lookup is done in that case) and
certain combinations of the 3 cells containing/
not-containing data are also valid.

When I run the function with all 3 cells empty, I get the
#VALUE! error. Can anyone spot what's triggering
the #VALUE! error, or suggest further debugging ideas?

Here is the code that runs when the #VALUE! error
occurs. I've added DEBUGGING messages to make
it easier to describe here what route the code takes.

DEBUGGING message (1) DOES occur and confirms
the empty contents of all 3 cells.

DEBUGGING message (2) DOES occur and confirms
that the code has recognized that all 3 cells are empty.

DEBUGGING message (3) DOES occur and shows
that the return value is set to "ERROR(7)".

DEBUGGING message (4) DOES NOT OCCUR,
confirming that the function() did in fact return with
its return value as set in message (3), and that No
further code was executed in the function().

CODE Snippet _________________________

Function checkHolidayHours( _
Optional holidayDate As Variant, _
Optional hours As Variant, _
Optional optHolFlag As Variant, _
Optional holidayDates As Range, _
Optional holidayNames As Range)

Dim holidayName As Variant
'(1) DEBUGGING
MsgBox ("Input to Function:" & vbCrLf & _
",holidayDate=" & holidayDate & _
",hours=" & hours & _
",optHolFlag=" & optHolFlag)

If (Len(holidayDate) = 0) Then
If (Len(hours) = 0 & Len(optHolFlag) = 0) Then
'(2) DEBUGGING
MsgBox ("Entry has no data")
checkHolidayHours = "ERROR(7)"
Else
MsgBox ("Hours and/or Optional Holiday Flag but no Date")
checkHolidayHours = "ERROR(2)"
End If
'(3) DEBUGGING
MsgBox ("Function return value is " & checkHolidayHours)
Return
End If

'(4) DEBUGGING
MsgBox ("Entry has data")

TIA

Phil
 
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
copy of excel file not showing formulal/function in the function b oaallam Excel Discussion (Misc queries) 4 September 6th 07 01:20 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
Emulate Index/Match combo function w/ VBA custom function Spencer Hutton Excel Worksheet Functions 2 May 2nd 05 05:26 PM
Nested IF Function, Date Comparing, and NetworkDays Function carl Excel Worksheet Functions 2 December 29th 04 09:57 PM


All times are GMT +1. The time now is 08:52 PM.

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

About Us

"It's about Microsoft Excel"