Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default What is default property of name object

Hi all,
I can use
Range("A1:a3").Name = "data"
to define a name object.

but Range("A1:a3").Name will display the address of the name object

Could you explain why?

Clara


--
thank you so much for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default What is default property of name object

Hi Clara,

The default property of a Name is RefersTo, hence if the name refers to a
range returning the default property will return its address

Maybe you want this -

On error resume next
s = ""
s = Range("A1:a3").Name.Name
on error goto 0
If len(s) then
msgbox s & vbcr & Range("A1:a3").Name
else
msgbox "the range is not defined"
End if

Regards,
Peter T

"clara" wrote in message
...
Hi all,
I can use
Range("A1:a3").Name = "data"
to define a name object.

but Range("A1:a3").Name will display the address of the name object

Could you explain why?

Clara


--
thank you so much for your help



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default What is default property of name object

Hi Peter,
Thank you very mcuh!
What I really mean is that there is an inconsistency here since we use
Range("A1:a3").Name = "data"( Set method) to assign a name, we can not
retrieve(Get) by referring to Range("A1:a3").Name

Clara
--
thank you so much for your help


"Peter T" wrote:

Hi Clara,

The default property of a Name is RefersTo, hence if the name refers to a
range returning the default property will return its address

Maybe you want this -

On error resume next
s = ""
s = Range("A1:a3").Name.Name
on error goto 0
If len(s) then
msgbox s & vbcr & Range("A1:a3").Name
else
msgbox "the range is not defined"
End if

Regards,
Peter T

"clara" wrote in message
...
Hi all,
I can use
Range("A1:a3").Name = "data"
to define a name object.

but Range("A1:a3").Name will display the address of the name object

Could you explain why?

Clara


--
thank you so much for your help




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default What is default property of name object

Hi again,

I see what you mean but it's not really an inconsistency

say you did -
Set rng = [a1]
then
v = rng
v returns the default property of the range which is its value, not the cell
reference or its name if it has one.

If you are trying to return your range's name then you need to return the
Name property of the Name object.
As before -
On error resume next ' in case the range doesn't have a Name
s = ""
s = Range("A1:a3").Name.Name

similarly
set nm = activeworkbook.names("test")
s = nm.Name ' 'test

Regards,
Peter T


"clara" wrote in message
...
Hi Peter,
Thank you very mcuh!
What I really mean is that there is an inconsistency here since we use
Range("A1:a3").Name = "data"( Set method) to assign a name, we can not
retrieve(Get) by referring to Range("A1:a3").Name

Clara
--
thank you so much for your help


"Peter T" wrote:

Hi Clara,

The default property of a Name is RefersTo, hence if the name refers to

a
range returning the default property will return its address

Maybe you want this -

On error resume next
s = ""
s = Range("A1:a3").Name.Name
on error goto 0
If len(s) then
msgbox s & vbcr & Range("A1:a3").Name
else
msgbox "the range is not defined"
End if

Regards,
Peter T

"clara" wrote in message
...
Hi all,
I can use
Range("A1:a3").Name = "data"
to define a name object.

but Range("A1:a3").Name will display the address of the name object

Could you explain why?

Clara


--
thank you so much for your help






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default What is default property of name object

Peter, Clara,

From Help:
Name property as it applies to the Font and Range objects.
Returns or sets the name of the object. The name of a Range object is a Name
object. For every other type of object, the name is a string. Read/write
Variant.
<This does not really help, as what does "the name of the object" mean in
this case ?

So, if a Name has been set for the range:
?typename(Range("A1").name)
Name

Which makes sense.
But then
Range("A1").name="Name1"
?Range("A1").Name.name
Name1
?names("name1").RefersTo
=Sheet3!$A$1

should not work, as the default property for a Name is RefersTo, but this is
clearly setting the Name.Name correctly.
It does seems some short-cut in the implementation, which, whilst useful,
can be confusing.

NickHK

"Peter T" <peter_t@discussions wrote in message
...
Hi again,

I see what you mean but it's not really an inconsistency

say you did -
Set rng = [a1]
then
v = rng
v returns the default property of the range which is its value, not the

cell
reference or its name if it has one.

If you are trying to return your range's name then you need to return the
Name property of the Name object.
As before -
On error resume next ' in case the range doesn't have a Name
s = ""
s = Range("A1:a3").Name.Name

similarly
set nm = activeworkbook.names("test")
s = nm.Name ' 'test

Regards,
Peter T


"clara" wrote in message
...
Hi Peter,
Thank you very mcuh!
What I really mean is that there is an inconsistency here since we use
Range("A1:a3").Name = "data"( Set method) to assign a name, we can not
retrieve(Get) by referring to Range("A1:a3").Name

Clara
--
thank you so much for your help


"Peter T" wrote:

Hi Clara,

The default property of a Name is RefersTo, hence if the name refers

to
a
range returning the default property will return its address

Maybe you want this -

On error resume next
s = ""
s = Range("A1:a3").Name.Name
on error goto 0
If len(s) then
msgbox s & vbcr & Range("A1:a3").Name
else
msgbox "the range is not defined"
End if

Regards,
Peter T

"clara" wrote in message
...
Hi all,
I can use
Range("A1:a3").Name = "data"
to define a name object.

but Range("A1:a3").Name will display the address of the name

object

Could you explain why?

Clara


--
thank you so much for your help









Reply
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
Object property/method problem Ayo Excel Discussion (Misc queries) 6 August 30th 07 10:18 PM
Lookin property of the FileSearch object [email protected] New Users to Excel 0 December 5th 06 09:37 PM
Using The Value property of the ActiveCell object Almamba Excel Programming 3 February 21st 05 06:38 PM
How to check if an object has a certain property? J Excel Programming 1 December 5th 04 11:58 AM
Page Object property Matt[_18_] Excel Programming 1 October 2nd 03 01:43 PM


All times are GMT +1. The time now is 12:24 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"