View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Mark is offline
external usenet poster
 
Posts: 102
Default Determine the text in a range that covers several cells


wrote:
I defined a name on a sheet that refers to the combined cells A1-A3. I
can set it to a text string but I can not read back what it contains.
Here is a snipit of my code that sets the value and then tries to test
what is stored in it.
I would appreciate any help in figuring out how to get the value of
this named range.
Thanks
Scott

Sub Test()
'LName is the combined range on the worksheet of cells A1 to A3
Worksheets("Sheet1").Range("LName") = "Anderson"
'Test to see what "LName" is
If Worksheets("Sheet1").Range(LName).FormulaR1C1 < "" Then MsgBox
"Yes"
If Worksheets("Sheet1").Range(LName).Value < "" Then MsgBox "Yes"
If Worksheets("Sheet1").Range(LName).Text < "" Then MsgBox "Yes"
If Worksheets("Sheet1").Range("LName").FormulaR1C1 < "" Then
MsgBox "Yes"
If Worksheets("Sheet1").Range("LName").Value < "" Then MsgBox
"Yes"
If Worksheets("Sheet1").Range("LName").Text(1) < "" Then MsgBox
"Yes"
End Sub



Because of the inconsistency in your code, I am having a difficult time
trying to understand what you are trying to accomplish. Sometimes you
refer to your NamedRange as Range(LName), other times it is
Range("LName"). Which is it?
Range(LName) would refer to a variable, in other words you would have
had to do something like this earlier in your code...

Dim LName as Range
Set LName = Application.ActiveCell

Range("LName") on the other hand would refer to a NamedRange. I am
guessing that is what you mean based on what you said, but you better
fix the syntax in your code first before you continue asking questions.
That alone may fix your problem, check it out.