Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Range Object Question

This may be more of an Excel Object/VBA question, but here goes...

I am working on a VSTO excel project, being developed in version 2003. I am
running through a series of excel Range Objects that are named ranges in a
workbook. Is there a way to identify the Name of the range in code?

I have a data mappings page that ties the ranges to a custom Object's
properties and I need to grab the Name associated with the active range/cell
so I can shove it in the object.

Any tips would be great.

thanks



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Range Object Question

selection.Name.Name (range object.Name returns a Name object )

if it doesn't have a name, you get an error. the selection must represent
the entirety of the cells in the range -

for example if the Selection is A1 and the range A1:B2 is named Horse, then
you would get an error. If the selection in A1:B2, then it would return
Horse.

This is how I would do it in VBA:

Sub TestName()
Dim nm As Name
On Error Resume Next
Set nm = Selection.Name
On Error GoTo 0
If Not nm Is Nothing Then
MsgBox nm.Name
Else
MsgBox "no name"
End If
End Sub


--
Regards,
Tom Ogilvy


"abillmeier" wrote in message
...
This may be more of an Excel Object/VBA question, but here goes...

I am working on a VSTO excel project, being developed in version 2003. I

am
running through a series of excel Range Objects that are named ranges in a
workbook. Is there a way to identify the Name of the range in code?

I have a data mappings page that ties the ranges to a custom Object's
properties and I need to grab the Name associated with the active

range/cell
so I can shove it in the object.

Any tips would be great.

thanks





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Range Object Question

Thanks for the assist, works great.


"Tom Ogilvy" wrote in message
...
selection.Name.Name (range object.Name returns a Name object )

if it doesn't have a name, you get an error. the selection must
represent
the entirety of the cells in the range -

for example if the Selection is A1 and the range A1:B2 is named Horse,
then
you would get an error. If the selection in A1:B2, then it would return
Horse.

This is how I would do it in VBA:

Sub TestName()
Dim nm As Name
On Error Resume Next
Set nm = Selection.Name
On Error GoTo 0
If Not nm Is Nothing Then
MsgBox nm.Name
Else
MsgBox "no name"
End If
End Sub


--
Regards,
Tom Ogilvy


"abillmeier" wrote in message
...
This may be more of an Excel Object/VBA question, but here goes...

I am working on a VSTO excel project, being developed in version 2003. I

am
running through a series of excel Range Objects that are named ranges in
a
workbook. Is there a way to identify the Name of the range in code?

I have a data mappings page that ties the ranges to a custom Object's
properties and I need to grab the Name associated with the active

range/cell
so I can shove it in the object.

Any tips would be great.

thanks







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
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
returning pivottable object from a range object Grant Excel Programming 2 September 27th 04 02:22 AM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Alan Beban[_3_] Excel Programming 0 August 1st 03 01:24 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


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