problem is case sensitivity, "Y" < "y"
i also shortened your code to the essentials :)
Try:
Const cdevFlag As String = "devFlag"
Function checkDevFlag() as Boolean
on error goto errH
checkDevFlag = (UCASE$(Range(cdevFlag)) = "Y")
endH:
exit function
errH:
debug.print "range ";cdevflag;" not found in activeworkbook"
End Function
--
keepITcool
|
www.XLsupport.com | keepITcool chello nl | amsterdam
pwrichcreek wrote :
I have a cell named "devFlag" in my spreadsheet and I want to examine
its contents in VBA code. The cell contains the value "Y", but this
code returns FALSE.
Const cdevFlag As String = "devFlag"
Const cchktot As String = "check_totals"
Function checkdevFlag() As Boolean
Dim rdevFlag As Range
Set rdevFlag = Names.Item(cdevFlag).RefersToRange
If (rdevFlag.Value = "y") Then
checkdevFlag = True
Else
checkdevFlag = False
End If
End Function
My intent is to use the function in other VBA code, but for testing
I've tried using the function in an IF as:
=IF(checkdevFlag(),"devFlag is y","not") this returns "not"
and as:
=checkdevFlag() this returns FALSE
Can someone see what I am doing wrong?
TIA,
Phil