View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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.