View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Named Range: Same Names, Multiple Workbooks with Same Sheet Name

Named ranges are interesting once you get into code... The XL application
holds worksbooks which holds worksheets which hold ranges. That is how the
object model is structured. So ranges only exist as part of a sheet as part
of a book. If you do not specify in code the book and sheet then the default
assumption is active workbook and active worksheet. This means that you
either have to select the book and sheet to get to the named range (certainly
not an optimal solution) or you need to explicitly reference the book and
sheet

Thisworkbook.sheets("Sheet1").Range("MyRangeName")

The other method to get at the global named ranges is

ThisWorkbook.Names("MyRangeName").RefersToRange

In either case you just need to be explicit in your references. If you are
not explicit then the activeworkbook and active worksheet will be the default.

***Note that when you are dealing with multiple workbooks and worksheets you
really want to be very explicit with ALL of your references. It makes the
code a lot easer to debug and less prone to errors as you are always in
charge of where your code is operating...

As for your second question keep the names as they are. It actually keeps
things a lot neater and tidier.
--
HTH...

Jim Thomlinson


"BEEJAY" wrote:

1: (will) have massive amounts of coding with Named Ranges.

Multiple WorkBooks, each having a sheet called "PRICE" and each having
multiple range names that are identical (although physical range would be
different).
Assume 2 or more workbooks are OPEN.
Is there any possibility that under any circumstances a range name can be
"picked up" from an open (but not active) workbook?

2: Based on the knowledge from the experts out there, even if there is no
problem as regards # 1, above, would it still be wise to custom name each
range name, based on the workbook it is in?

Thanks for your input in advance.