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

Sorry! Of course there must be:

.....
If LCase([cdevFlag])= "y" Then



--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )


"Arvi Laanemets" wrote in message
...
Hi

Function checkdevFlag() As Boolean
If Lower([cdevFlag])= "y" Then
checkdevFlag = True
Else
checkdevFlag = False
End If
End Function


PS. You can read the value from any named range in VBA using syntax
[RangeName]. I´m not sure though, what you get when you refer to range
which contains several cells.

--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )


"pwrichcreek" wrote in message
...
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