View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
pwrichcreek pwrichcreek is offline
external usenet poster
 
Posts: 34
Default Code that references the name of a cell

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