Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Reference a named range

My data spreadsheet has several named ranges, with meaningful names. I'd like
to refer to them in VBA, but all attempts so far lead me to absolute
addresses like $R1$C1, or sheet1!R23C45. If a user cselects a named range how
can I read the name of the range (that might be a sinlge cell) and how can I
write to another named range (that will have many cells)?
Many thanks whoever is out there.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Reference a named range

If the the selection is the entire named range and nothing else

msgbox selection.name.name

if the user selects A1:B2 and the named range is only A1, then
selection.Name.Name will return an error.

Other than that, you would have to loop through the names collection and
test where the selection is relative to each named range.


You can refer to a known named range with

set rng = Range("MyNamedRange")

selection.Copy Destination:=rng

--
Regards,
Tom Ogilvy


"John M." wrote in message
...
My data spreadsheet has several named ranges, with meaningful names. I'd

like
to refer to them in VBA, but all attempts so far lead me to absolute
addresses like $R1$C1, or sheet1!R23C45. If a user cselects a named range

how
can I read the name of the range (that might be a sinlge cell) and how can

I
write to another named range (that will have many cells)?
Many thanks whoever is out there.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Reference a named range

Great, thanks Tom. "name.name" is one of the less intuitive versions that I
did not try. I can pre-filter all multiple selections and get exactly what I
need. Best wishes

"Tom Ogilvy" wrote:

If the the selection is the entire named range and nothing else

msgbox selection.name.name

if the user selects A1:B2 and the named range is only A1, then
selection.Name.Name will return an error.

Other than that, you would have to loop through the names collection and
test where the selection is relative to each named range.


You can refer to a known named range with

set rng = Range("MyNamedRange")

selection.Copy Destination:=rng

--
Regards,
Tom Ogilvy


"John M." wrote in message
...
My data spreadsheet has several named ranges, with meaningful names. I'd

like
to refer to them in VBA, but all attempts so far lead me to absolute
addresses like $R1$C1, or sheet1!R23C45. If a user cselects a named range

how
can I read the name of the range (that might be a sinlge cell) and how can

I
write to another named range (that will have many cells)?
Many thanks whoever is out there.




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
reference first cell in a named range Robert H Excel Worksheet Functions 3 January 14th 08 07:53 PM
Simple: how to express this named-range reference? [email protected] Excel Discussion (Misc queries) 5 May 28th 07 01:22 PM
automatic range - named range give me circular reference... George Thorogood Excel Discussion (Misc queries) 0 February 22nd 07 07:53 PM
Named Range reference via single Cell Graham Excel Discussion (Misc queries) 0 July 26th 06 09:37 AM
named range, offset self-reference George Excel Discussion (Misc queries) 6 November 6th 05 11:21 PM


All times are GMT +1. The time now is 08:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"